From e489edadfb87d3dd5f1ae3fe3f73f2ad74c36e34 Mon Sep 17 00:00:00 2001 From: autoscatto Date: Fri, 25 Sep 2020 12:55:05 +0200 Subject: [PATCH] setuppez --- .editorconfig | 21 ++++++ .gitignore | 107 +++++++++++++++++++++++++++- AUTHORS.rst | 13 ++++ CONTRIBUTING.rst | 8 +++ HISTORY.rst | 8 +++ LICENSE | 22 ++++++ MANIFEST.in | 11 +++ Makefile | 85 ++++++++++++++++++++++ README.rst | 21 ++++++ ananas2dec.py | 10 --- avocado2dec.py | 10 --- banana.py | 88 ----------------------- banana.svg | 1 + banana/__init__.py | 5 ++ banana/bananalib.py | 81 +++++++++++++++++++++ banana/cli.py | 110 ++++++++++++++++++++++++++++ banana2dec.py | 13 ---- bananarandom.py | 13 ---- dec2ananas.py | 11 --- dec2avocado.py | 11 --- dec2banana.py | 14 ---- dec2ribes.py | 11 --- docs/Makefile | 20 ++++++ docs/authors.rst | 1 + docs/banana.rst | 30 ++++++++ docs/conf.py | 162 ++++++++++++++++++++++++++++++++++++++++++ docs/contributing.rst | 1 + docs/history.rst | 1 + docs/index.rst | 20 ++++++ docs/installation.rst | 51 +++++++++++++ docs/make.bat | 36 ++++++++++ docs/modules.rst | 7 ++ docs/readme.rst | 1 + docs/usage.rst | 16 +++++ isbanana.py | 13 ---- requirements_dev.txt | 12 ++++ ribes2dec.py | 10 --- setup.cfg | 26 +++++++ setup.py | 65 +++++++++++++++++ tests/__init__.py | 1 + tests/test_banana.py | 14 ++++ tox.ini | 27 +++++++ 42 files changed, 981 insertions(+), 207 deletions(-) create mode 100644 .editorconfig create mode 100644 AUTHORS.rst create mode 100644 CONTRIBUTING.rst create mode 100644 HISTORY.rst create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.rst delete mode 100755 ananas2dec.py delete mode 100755 avocado2dec.py delete mode 100755 banana.py create mode 100644 banana.svg create mode 100644 banana/__init__.py create mode 100644 banana/bananalib.py create mode 100644 banana/cli.py delete mode 100755 banana2dec.py delete mode 100755 bananarandom.py delete mode 100755 dec2ananas.py delete mode 100755 dec2avocado.py delete mode 100755 dec2banana.py delete mode 100755 dec2ribes.py create mode 100644 docs/Makefile create mode 100644 docs/authors.rst create mode 100644 docs/banana.rst create mode 100755 docs/conf.py create mode 100644 docs/contributing.rst create mode 100644 docs/history.rst create mode 100644 docs/index.rst create mode 100644 docs/installation.rst create mode 100644 docs/make.bat create mode 100644 docs/modules.rst create mode 100644 docs/readme.rst create mode 100644 docs/usage.rst delete mode 100755 isbanana.py create mode 100644 requirements_dev.txt delete mode 100755 ribes2dec.py create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/test_banana.py create mode 100644 tox.ini diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d4a2c44 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 +end_of_line = lf + +[*.bat] +indent_style = tab +end_of_line = crlf + +[LICENSE] +insert_final_newline = false + +[Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore index ab8a108..dd05858 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,106 @@ +# Byte-compiled / optimized / DLL files __pycache__/ -*.txt -*.xls -.~lock.Banana.xls# +*.py[cod] +*$py.class +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# IDE settings +.vscode/ diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 0000000..c348351 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,13 @@ +======= +Credits +======= + +Development Lead +---------------- + +* itec + +Contributors +------------ + +None yet. Why not be the first? diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..09f2595 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,8 @@ +.. highlight:: shell + +============ +Contributing +============ + +Contributions are welcome, and they are greatly appreciated! Every little bit +helps, and credit will always be given. diff --git a/HISTORY.rst b/HISTORY.rst new file mode 100644 index 0000000..4019e19 --- /dev/null +++ b/HISTORY.rst @@ -0,0 +1,8 @@ +======= +History +======= + +0.1.0 (2020-09-25) +------------------ + +* NOPE. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f723fe1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2020, itec + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..965b2dd --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,11 @@ +include AUTHORS.rst +include CONTRIBUTING.rst +include HISTORY.rst +include LICENSE +include README.rst + +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] + +recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..864f7b2 --- /dev/null +++ b/Makefile @@ -0,0 +1,85 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -fr .tox/ + rm -f .coverage + rm -fr htmlcov/ + rm -fr .pytest_cache + +lint: ## check style with flake8 + flake8 banana tests + +test: ## run tests quickly with the default Python + pytest + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source banana -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +docs: ## generate Sphinx HTML documentation, including API docs + rm -f docs/banana.rst + rm -f docs/modules.rst + sphinx-apidoc -o docs/ banana + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs/_build/html/index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: dist ## package and upload a release + twine upload dist/* + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + ls -l dist + +install: clean ## install the package to the active Python's site-packages + python setup.py install diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..bfb05e3 --- /dev/null +++ b/README.rst @@ -0,0 +1,21 @@ +====== +banana +====== + + +.. image:: https://img.shields.io/travis/itec/banana.svg?label=banana&color=fedcba&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAABgAAAAVCAYAAABc6S4mAAAACXBIWXMAAABmAAAAZgEHbzbCAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm%2B48GgAAA3lJREFUOI2tlW1olWUYx3%2F38zznOWfPOdvT2WkenRZae3GkbWRva2PVRkYYkawpyvqQ6CAalZiwihgVlCQYgaUzEwMJlvYhMEr6ECc13Ha%2BlGm23MZglrpZnb2ct%2Be577sPdcKCEem5Pt1cXPf1%2B%2F%2Fv%2B4ILihu1wBAwBXQCGEUGbFnbFpg1BNqxeRGoLGp32%2BLzqeNuqn6xOL5%2FY2AA2FJMB5GoK2KljghLjXi83qgFWosJaGt%2FyE5nczqrNcTCwnVDuEUDWCbPvLw5tOL0T2qiusLwAUoCwikWoK1llWXHYyKWSHpTjcuEBWAalBQDEAnZvNa%2FM9wA8NWQ77fVmnEAqclfN8Aw2PPRjrATLROuVMgz56Sz6mZRBZD3dO56AW9s7ihf8NjqpXmAg5%2Fmk4%2FUGWmAnE8ulWXOulbhwDtdHZHl771kLcO%2FFPR8vN7dGeNsj90AcHJEnZeawWtxcIttcfTV7oravQeOLhIEPLS%2FZGPP3MkXWkwv6ggXYMeXchI49n8clANPL6wQa4590JBZ%2BeDuRXq0w9QqXdN3OD9wcdQX27YF7wPIeGROjEgFJP8LEAWagTXxmGjYuT0%2B17npFdAypM4%2FWgna3dOfO7Xr%2FSzDvcGmwqXuj73BjMc%2BAAtoATYBDpACTCGoKHVESewGw1m%2FOuA%2F2b7YqGt80wRVqi9sL9FyZkUuT65962wif0Uy3BtssgwsgB8v6%2FFDQ3IG6AcQwCQQSRyIjK2sNm%2FyJX60TLhCIAqKhFEyrFU%2BArJSKuT%2BT3JDr%2B%2FNGj2tpnzuAavxrzL1%2Fc860fR2LjCdYQMwUQAkbJOlbkRcvud2a7brCbu89V6rJmSLUAHgS%2FzkGTnSdyT7yxcJv%2BzhWmO6b0PgbsfGAbiSJvnthNJr9%2BXVdJZuIPm3OKChsky8m9gatCZ%2BV87BU3LqmzEVzEqE0gjbwg9b6Lq44Xc1mze21Ri3CYHwFJMXU%2FwwNacWDI1r9fwRbybj0QV8d%2FUnFp7hzlCAXevuML1n7zddNyRmQwGMUEAELVMHtUYqJWTG09nZnNJZT8SlpurXNKnez7zTg%2BP6glR0A7%2F9e0rEVWcbeCocYF1zlWl03mUsWb5Q3Cr%2BWYMnyZ8YVWc%2FHJDT5y7pGV%2FyFvD1fGMo5snXA%2BuDFtVlIUqVFlGAdF6rrMeE%2FnPvHgbG5mtciD8AcJRb8mo4BE0AAAAASUVORK5CYII%3D + :target: https://travis-ci.com/itec/banana + + +* Free software: MIT license +* Documentation: https://git.lattuga.net/itec/banana. + + +Features +-------- + +* TODO + +Credits +------- +All hail Stefano Bartezzaghi diff --git a/ananas2dec.py b/ananas2dec.py deleted file mode 100755 index 1b4ccb8..0000000 --- a/ananas2dec.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert ananas string to dec") - parser.add_argument("ananas", help="String to be converted") - args = parser.parse_args() - - print(banana.banana2dec(args.ananas, 1, 0)) diff --git a/avocado2dec.py b/avocado2dec.py deleted file mode 100755 index 23284f5..0000000 --- a/avocado2dec.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert avocado string to dec") - parser.add_argument("avocado", help="String to be converted") - args = parser.parse_args() - - print(banana.banana2dec(args.avocado, 1, 0)) diff --git a/banana.py b/banana.py deleted file mode 100755 index 9d85a0d..0000000 --- a/banana.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python3 - -def dec2banana(num, dictstart = None, shiftend = None, minlength = None, dictionary = None): - #defaults - if dictstart is None: dictstart = 0 - if shiftend is None: shiftend = 0 - if minlength is None: minlength = 0 - if dictionary is None: dictionary = [list("bcdfglmnprstvz"), list("aeiou")] - - numdict = len(dictionary) - v = num - st = "" - l = 0 - - i = (numdict - 1 + dictstart + shiftend) % numdict - while not (v == 0 and i == (numdict - 1 + dictstart) % numdict and l >= minlength): - r = v % len(dictionary[i]) - v = int(v / len(dictionary[i])) - st = dictionary[i][r] + st - i = (i - 1) % numdict - l += 1 - - return(st) - - -def banana2dec(banana, dictstart = None, shiftend = None, dictionary = None): - #defaults - if dictstart is None: dictstart = 0 - if shiftend is None: shiftend = 0 - if dictionary is None: dictionary = [list("bcdfglmnprstvz"), list("aeiou")] #, list("123456") - - numdict = len(dictionary) - if (len(banana) - shiftend) % numdict != 0: - return("Banana non valida") - v = 0 - for i in range(len(banana)): - r = (numdict + i + dictstart) % numdict - try: - v = v * len(dictionary[r]) + dictionary[r].index(banana[i]) - except: - return("Carattere non valido in posizione", i+1) - - return(v) - -def bananarandom(dictstart = None, shiftend = None, minlength = None, dictionary = None): - import random - - #defaults - if dictstart is None: dictstart = 0 - if shiftend is None: shiftend = 0 - if minlength is None: minlength = 6 - if dictionary is None: dictionary = [list("bcdfglmnprstvz"), list("aeiou")] - - numdict = len(dictionary) - st = "" - l = 0 - - i = (numdict - 1 + dictstart + shiftend) % numdict - while not (i == (numdict - 1 + dictstart) % numdict and l >= minlength): - r = random.randint(0, len(dictionary[i]) - 1) - st = dictionary[i][r] + st - i = (i - 1) % numdict - l += 1 - - return(st) - -def isbanana(banana, dictstart = None, shiftend = None, dictionary = None): - #defaults - if dictstart is None: dictstart = 0 - if shiftend is None: shiftend = 0 - if dictionary is None: dictionary = [list("bcdfglmnprstvz"), list("aeiou")] #, list("123456") - - numdict = len(dictionary) - if (len(banana) - shiftend) % numdict != 0: - return(False) - for i in range(len(banana)): - r = (numdict + i + dictstart) % numdict - if banana[i] not in dictionary[r]: - return(False) - - return(True) - - - - - -if __name__ == "__main__": - print("Ciao sono la libreria banana") diff --git a/banana.svg b/banana.svg new file mode 100644 index 0000000..a7fb1e8 --- /dev/null +++ b/banana.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/banana/__init__.py b/banana/__init__.py new file mode 100644 index 0000000..293774d --- /dev/null +++ b/banana/__init__.py @@ -0,0 +1,5 @@ +"""Top-level package for banana.""" + +__author__ = """itec""" +__email__ = 'itec@ventuordici.org' +__version__ = '0.1.0' diff --git a/banana/bananalib.py b/banana/bananalib.py new file mode 100644 index 0000000..430e0a8 --- /dev/null +++ b/banana/bananalib.py @@ -0,0 +1,81 @@ +"""Main module.""" + + +def dec2banana(num, dictstart=0, shiftend=0, minlength=0, dictionary=None): + if dictionary is None: + dictionary = [list("bcdfglmnprstvz"), list("aeiou")] + + numdict = len(dictionary) + v = num + st = "" + length = 0 + + idx = (numdict - 1 + dictstart + shiftend) % numdict + while not (v == 0 and idx == (numdict - 1 + dictstart) % numdict and length >= minlength): + r = v % len(dictionary[idx]) + v = int(v / len(dictionary[idx])) + st = dictionary[idx][r] + st + idx = (idx - 1) % numdict + length += 1 + + return st + + +def banana2dec(banana, dictstart=0, shiftend=0, dictionary=None): + # defaults + if dictionary is None: + dictionary = [list("bcdfglmnprstvz"), list("aeiou")] # , list("123456") + + numdict = len(dictionary) + if (len(banana) - shiftend) % numdict != 0: + return "Banana non valida" + v = 0 + for i in range(len(banana)): + r = (numdict + i + dictstart) % numdict + try: + v = v * len(dictionary[r]) + dictionary[r].index(banana[i]) + except (ValueError, KeyError) as e: + return "Carattere non valido in posizione", i + 1 + + return v + + +def bananarandom(dictstart=0, shiftend=0, minlength=6, dictionary=None): + import random + + # defaults + if dictionary is None: + dictionary = [list("bcdfglmnprstvz"), list("aeiou")] + + numdict = len(dictionary) + st = "" + length = 0 + + i = (numdict - 1 + dictstart + shiftend) % numdict + while not (i == (numdict - 1 + dictstart) % numdict and length >= minlength): + r = random.randint(0, len(dictionary[i]) - 1) + st = dictionary[i][r] + st + i = (i - 1) % numdict + length += 1 + + return st + + +def isbanana(banana, dictstart=0, shiftend=0, dictionary=None): + # defaults + if dictionary is None: + dictionary = [list("bcdfglmnprstvz"), list("aeiou")] # , list("123456") + + numdict = len(dictionary) + if (len(banana) - shiftend) % numdict != 0: + return False + for i in range(len(banana)): + r = (numdict + i + dictstart) % numdict + if banana[i] not in dictionary[r]: + return False + + return True + + +if __name__ == "__main__": + print("Ciao sono la libreria banana") diff --git a/banana/cli.py b/banana/cli.py new file mode 100644 index 0000000..d29aa97 --- /dev/null +++ b/banana/cli.py @@ -0,0 +1,110 @@ +"""Console script for banana.""" +import argparse +from . import bananalib as banana +import sys + + +def ananas2dec(): + parser = argparse.ArgumentParser(description="Convert ananas string to dec") + parser.add_argument("ananas", help="String to be converted") + args = parser.parse_args() + + print(banana.banana2dec(args.ananas, 1, 0)) + + +def avocado2dec(): + parser = argparse.ArgumentParser(description="Convert avocado string to dec") + parser.add_argument("avocado", help="String to be converted") + args = parser.parse_args() + + print(banana.banana2dec(args.avocado, 1, 0)) + + +def banana2dec(): + parser = argparse.ArgumentParser(description="Convert banana string to dec") + parser.add_argument("banana", help="String to be converted") + parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') + parser.add_argument("--dictstart", help="Set starting dictionary", type=int, default=0) + parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int, default=0) + args = parser.parse_args() + + print(banana.banana2dec(args.banana, args.dictstart, args.shiftend, args.dictionary)) + + +def ribes2dec(): + parser = argparse.ArgumentParser(description="Convert ribes string to dec") + parser.add_argument("ribes", help="String to be converted") + args = parser.parse_args() + + print(banana.banana2dec(args.ribes, 1, 0)) + + +def bananarandom(): + parser = argparse.ArgumentParser(description="Generate random banana") + parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') + parser.add_argument("--dictstart", help="Set starting dictionary", type=int, default=0) + parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int, default=0) + parser.add_argument("--minlength", help="Set minimum length", type=int, default=6) + args = parser.parse_args() + + print(banana.bananarandom(args.dictstart, args.shiftend, args.minlength, args.dictionary)) + + +def dec2ananas(): + parser = argparse.ArgumentParser(description="Convert dec number to ananas") + parser.add_argument("num", help="Number to be converted", type=int) + parser.add_argument("--minlength", help="Set minimum length", type=int, default=0) + args = parser.parse_args() + + print(banana.dec2banana(args.num, 1, 0, args.minlength)) + + +def dec2avocado(): + parser = argparse.ArgumentParser(description="Convert dec number to avocado") + parser.add_argument("num", help="Number to be converted", type=int) + parser.add_argument("--minlength", help="Set minimum length", type=int, default=0) + args = parser.parse_args() + + print(banana.dec2banana(args.num, 1, 1, args.minlength)) + + +def dec2banana(): + parser = argparse.ArgumentParser(description="Convert dec number to banana") + parser.add_argument("num", help="Number to be converted", type=int) + parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') + parser.add_argument("--dictstart", help="Set starting dictionary", type=int, default=0) + parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int, default=0) + parser.add_argument("--minlength", help="Set minimum length", type=int, default=0) + args = parser.parse_args() + + print(banana.dec2banana(args.num, args.dictstart, args.shiftend, args.minlength, args.dictionary)) + + +def dec2ribes(): + parser = argparse.ArgumentParser(description="Convert dec number to ribes") + parser.add_argument("num", help="Number to be converted", type=int) + parser.add_argument("--minlength", help="Set minimum length", type=int, default=0) + args = parser.parse_args() + + print(banana.dec2banana(args.num, 1, 1, args.minlength)) + + +def isbanana(): + parser = argparse.ArgumentParser(description="Checks if string is banana") + parser.add_argument("banana", help="String to be checked") + parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') + parser.add_argument("--dictstart", help="Set starting dictionary", type=int, default=0) + parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int, default=0) + args = parser.parse_args() + + print(banana.isbanana(args.banana, args.dictstart, args.shiftend, args.dictionary)) + + +def main(): + sys.exit(bananarandom()) + + +if __name__ == "__main__": + # pragma: no cover + main() + diff --git a/banana2dec.py b/banana2dec.py deleted file mode 100755 index 840c887..0000000 --- a/banana2dec.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert banana string to dec") - parser.add_argument("banana", help="String to be converted") - parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') - parser.add_argument("--dictstart", help="Set starting dictionary", type=int) - parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int) - args = parser.parse_args() - - print(banana.banana2dec(args.banana, args.dictstart, args.shiftend, args.dictionary)) diff --git a/bananarandom.py b/bananarandom.py deleted file mode 100755 index d9c31ac..0000000 --- a/bananarandom.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Generate random banana") - parser.add_argument("--dictstart", help="Set starting dictionary", type=int) - parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int) - parser.add_argument("--minlength", help="Set minimum length", type=int) - parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') - args = parser.parse_args() - - print(banana.bananarandom(args.dictstart, args.shiftend, args.minlength, args.dictionary)) diff --git a/dec2ananas.py b/dec2ananas.py deleted file mode 100755 index 269f1cb..0000000 --- a/dec2ananas.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert dec number to ananas") - parser.add_argument("num", help="Number to be converted", type=int) - parser.add_argument("--minlength", help="Set minimum length", type=int) - args = parser.parse_args() - - print(banana.dec2banana(args.num, 1, 0, args.minlength)) diff --git a/dec2avocado.py b/dec2avocado.py deleted file mode 100755 index 781d009..0000000 --- a/dec2avocado.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert dec number to avocado") - parser.add_argument("num", help="Number to be converted", type=int) - parser.add_argument("--minlength", help="Set minimum length", type=int) - args = parser.parse_args() - - print(banana.dec2banana(args.num, 1, 1, args.minlength)) diff --git a/dec2banana.py b/dec2banana.py deleted file mode 100755 index da26df4..0000000 --- a/dec2banana.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert dec number to banana") - parser.add_argument("num", help="Number to be converted", type=int) - parser.add_argument("--dictstart", help="Set starting dictionary", type=int) - parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int) - parser.add_argument("--minlength", help="Set minimum length", type=int) - parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') - args = parser.parse_args() - - print(banana.dec2banana(args.num, args.dictstart, args.shiftend, args.minlength, args.dictionary)) diff --git a/dec2ribes.py b/dec2ribes.py deleted file mode 100755 index 03e9172..0000000 --- a/dec2ribes.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert dec number to ribes") - parser.add_argument("num", help="Number to be converted", type=int) - parser.add_argument("--minlength", help="Set minimum length", type=int) - args = parser.parse_args() - - print(banana.dec2banana(args.num, 1, 1, args.minlength)) diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..93bc4e6 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = python -msphinx +SPHINXPROJ = banana +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/authors.rst b/docs/authors.rst new file mode 100644 index 0000000..e122f91 --- /dev/null +++ b/docs/authors.rst @@ -0,0 +1 @@ +.. include:: ../AUTHORS.rst diff --git a/docs/banana.rst b/docs/banana.rst new file mode 100644 index 0000000..09bae66 --- /dev/null +++ b/docs/banana.rst @@ -0,0 +1,30 @@ +banana package +============== + +Submodules +---------- + +banana.bananalib module +----------------------- + +.. automodule:: banana.bananalib + :members: + :undoc-members: + :show-inheritance: + +banana.cli module +----------------- + +.. automodule:: banana.cli + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: banana + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/conf.py b/docs/conf.py new file mode 100755 index 0000000..7343310 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,162 @@ +#!/usr/bin/env python +# +# banana documentation build configuration file, created by +# sphinx-quickstart on Fri Jun 9 13:47:02 2017. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another +# directory, add these directories to sys.path here. If the directory is +# relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('..')) + +import banana + +# -- General configuration --------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'banana' +copyright = "2020, itec" +author = "itec" + +# The version info for the project you're documenting, acts as replacement +# for |version| and |release|, also used in various other places throughout +# the built documents. +# +# The short X.Y version. +version = banana.__version__ +# The full version, including alpha/beta/rc tags. +release = banana.__version__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a +# theme further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + + +# -- Options for HTMLHelp output --------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'bananadoc' + + +# -- Options for LaTeX output ------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'banana.tex', + 'banana Documentation', + 'itec', 'manual'), +] + + +# -- Options for manual page output ------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'banana', + 'banana Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'banana', + 'banana Documentation', + author, + 'banana', + 'One line description of project.', + 'Miscellaneous'), +] + + + diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 0000000..e582053 --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/history.rst b/docs/history.rst new file mode 100644 index 0000000..2506499 --- /dev/null +++ b/docs/history.rst @@ -0,0 +1 @@ +.. include:: ../HISTORY.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..3a5a315 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +Welcome to banana's documentation! +====================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + readme + installation + usage + modules + contributing + authors + history + +Indices and tables +================== +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 0000000..4cae0d8 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,51 @@ +.. highlight:: shell + +============ +Installation +============ + + +Stable release +-------------- + +To install banana, run this command in your terminal: + +.. code-block:: console + + $ pip install banana + +This is the preferred method to install banana, as it will always install the most recent stable release. + +If you don't have `pip`_ installed, this `Python installation guide`_ can guide +you through the process. + +.. _pip: https://pip.pypa.io +.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ + + +From sources +------------ + +The sources for banana can be downloaded from the `Gogs repo`_. + +You can either clone the public repository: + +.. code-block:: console + + $ git clone https://git.lattuga.net/itec/banana + +Or download the `tarball`_: + +.. code-block:: console + + $ curl -OJL https://git.lattuga.net/itec/banana/archive/master.tar.gz + +Once you have a copy of the source, you can install it with: + +.. code-block:: console + + $ python setup.py install + + +.. _Gogs repo: https://git.lattuga.net/itec/banana +.. _tarball: https://git.lattuga.net/itec/banana/archive/master.tar.gz diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..5ba337d --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=python -msphinx +) +set SOURCEDIR=. +set BUILDDIR=_build +set SPHINXPROJ=banana + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The Sphinx module was not found. Make sure you have Sphinx installed, + echo.then set the SPHINXBUILD environment variable to point to the full + echo.path of the 'sphinx-build' executable. Alternatively you may add the + echo.Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/modules.rst b/docs/modules.rst new file mode 100644 index 0000000..443315e --- /dev/null +++ b/docs/modules.rst @@ -0,0 +1,7 @@ +banana +====== + +.. toctree:: + :maxdepth: 4 + + banana diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 0000000..72a3355 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 0000000..560f22b --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,16 @@ +===== +Usage +===== +To use banana in a project + +.. code-block:: python + + from banana import bananalib + + +====== +Script +====== +Available cli scripts: + + diff --git a/isbanana.py b/isbanana.py deleted file mode 100755 index c4c9ddc..0000000 --- a/isbanana.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Checks if string is banana") - parser.add_argument("banana", help="String to be checked") - parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+') - parser.add_argument("--dictstart", help="Set starting dictionary", type=int) - parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int) - args = parser.parse_args() - - print(banana.isbanana(args.banana, args.dictstart, args.shiftend, args.dictionary)) diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..8606480 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,12 @@ +pip==19.2.3 +bump2version==0.5.11 +wheel==0.33.6 +watchdog==0.9.0 +flake8==3.7.8 +tox==3.14.0 +coverage==4.5.4 +Sphinx==1.8.5 +twine==1.14.0 + +pytest==4.6.5 +pytest-runner==5.1 \ No newline at end of file diff --git a/ribes2dec.py b/ribes2dec.py deleted file mode 100755 index 865180f..0000000 --- a/ribes2dec.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import banana - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Convert ribes string to dec") - parser.add_argument("ribes", help="String to be converted") - args = parser.parse_args() - - print(banana.banana2dec(args.ribes, 1, 0)) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..77f55ea --- /dev/null +++ b/setup.cfg @@ -0,0 +1,26 @@ +[bumpversion] +current_version = 0.1.0 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version='{current_version}' +replace = version='{new_version}' + +[bumpversion:file:banana/__init__.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs + +[aliases] +# Define setup.py command aliases here +test = pytest + +[tool:pytest] +collect_ignore = ['setup.py'] + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6e81cad --- /dev/null +++ b/setup.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +"""The setup script.""" + +from setuptools import setup, find_packages + +with open('README.rst') as readme_file: + readme = readme_file.read() + +with open('HISTORY.rst') as history_file: + history = history_file.read() + +requirements = [ + +] + +setup_requirements = ['pytest-runner', ] + +test_requirements = ['pytest>=3', ] + +setup( + author="itec", + author_email='itec@ventuordici.org', + python_requires='>=3.5', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + ], + description="banana", + entry_points={ + 'console_scripts': [ + 'banana=banana.cli:main', + 'ananas2dec=banana.cli:ananas2dec', + 'avocado2dec=banana.cli:avocado2dec', + 'banana2dec=banana.cli:banana2dec', + 'ribes2dec=banana.cli:ribes2dec', + 'bananarandom=banana.cli:bananarandom', + 'dec2ananas=banana.cli:dec2ananas', + 'dec2avocado=banana.cli:dec2avocado', + 'dec2banana=banana.cli:dec2banana', + 'dec2ribes=banana.cli:dec2ribes', + 'isbanana=banana.cli:isbanana' + ], + }, + install_requires=requirements, + license="MIT license", + long_description=readme + '\n\n' + history, + include_package_data=True, + keywords='banana', + name='banana', + packages=find_packages(include=['banana', 'banana.*']), + setup_requires=setup_requirements, + test_suite='tests', + tests_require=test_requirements, + url='https://git.lattuga.net/itec/banana', + version='0.1.0', + zip_safe=False, +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..5efbeb1 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Unit test package for banana.""" diff --git a/tests/test_banana.py b/tests/test_banana.py new file mode 100644 index 0000000..1652ac2 --- /dev/null +++ b/tests/test_banana.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +"""Tests for `banana` package.""" + +import pytest + + +from banana import bananalib + + +def test_answer_to_life_the_universe_and_everything(): + banana = bananalib.banana2dec("banana") + assert banana != 42 + assert banana == 2485 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..667f9a5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,27 @@ +[tox] +envlist = py35, py36, py37, py38, flake8 + +[travis] +python = + 3.8: py38 + 3.7: py37 + 3.6: py36 + 3.5: py35 + +[testenv:flake8] +basepython = python +deps = flake8 +commands = flake8 banana tests + +[testenv] +setenv = + PYTHONPATH = {toxinidir} +deps = + -r{toxinidir}/requirements_dev.txt +; If you want to make tox run the tests with the same versions, create a +; requirements.txt with the pinned versions and uncomment the following line: +; -r{toxinidir}/requirements.txt +commands = + pip install -U pip + pytest --basetemp={envtmpdir} +