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 e13801c commit 29c608e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 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
8 changes: 6 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
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",
]
6 changes: 3 additions & 3 deletions src/nameless/_core.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Python.h"

static PyObject* main(PyObject *self, PyObject *value) {
static PyObject* compute(PyObject *self, PyObject *value) {
PyObject *module;
PyObject *module_dict;
PyObject *len;
Expand Down Expand Up @@ -47,10 +47,10 @@ static PyObject* main(PyObject *self, PyObject *value) {
return result;
}

PyDoc_STRVAR(main_doc, "Docstring for main function.");
PyDoc_STRVAR(compute_doc, "Docstring for compute function.");

static struct PyMethodDef module_functions[] = {
{"main", main, METH_O, main_doc},
{"compute", compute, METH_O, compute_doc},
{NULL, NULL}
};

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
@@ -1,6 +1,6 @@
try:
from ._core import main
from ._core import compute
except ImportError:

def main(args):
def compute(args):
return max(args, key=len)
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"

0 comments on commit 29c608e

Please sign in to comment.