Skip to content

Commit

Permalink
Up.
Browse files Browse the repository at this point in the history
  • Loading branch information
ionelmc committed Mar 23, 2024
1 parent c03de91 commit 2dc96a1
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions .cookiecutterrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ default_context:
email: [email protected]
formatter_quote_style: double
full_name: Ionel Cristian Mărieș
function_name: compute
github_actions: 'yes'
github_actions_osx: 'yes'
github_actions_windows: 'yes'
Expand Down
7 changes: 5 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Usage
=====

To use Nameless in a project::
To use the project:

import nameless
.. code-block:: python
import nameless
nameless.compute(...)
4 changes: 2 additions & 2 deletions src/nameless/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__version__ = "0.1.0"

from .core import main
from .core import compute

__all__ = [
"main",
"compute",
]
2 changes: 1 addition & 1 deletion src/nameless/_core.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

char* main(int argc, char *argv[]) {
char* compute(int argc, char *argv[]) {
if (argc) {
int len, i,
max = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/nameless/_core_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ffi = FFI()
ffi.cdef(
"""
char* main(int argv, char *argv[]);
char* compute(int argv, char *argv[]);
"""
)

Expand Down
4 changes: 2 additions & 2 deletions src/nameless/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import argparse

from .core import main
from .core import compute

parser = argparse.ArgumentParser(description="Command description.")
parser.add_argument(
Expand All @@ -30,5 +30,5 @@

def run(args=None):
args = parser.parse_args(args=args)
print(main(args.names))
print(compute(args.names))
parser.exit(0)
4 changes: 2 additions & 2 deletions src/nameless/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from ._core import lib as _lib


def main(args):
def compute(args):
args = [_ffi.new("char[]", arg.encode()) for arg in args]
result = _lib.main(len(args), _ffi.new("char *[]", args))
result = _lib.compute(len(args), _ffi.new("char *[]", args))
if result == _ffi.NULL:
return None
else:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from nameless import main
from nameless import compute


def test_main():
assert main(["a", "bc", "abc"]) == "abc"
def test_compute():
assert compute(["a", "bc", "abc"]) == "abc"
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ install_command =
deps =
-r{toxinidir}/docs/requirements.txt
commands =
python setup.py clean --all build_ext --force --inplace
sphinx-build {posargs:-E} -b doctest docs dist/docs
sphinx-build {posargs:-E} -b html docs dist/docs
sphinx-build -b linkcheck docs dist/docs
Expand Down

0 comments on commit 2dc96a1

Please sign in to comment.