1
0
Fork 0
forked from itec/banana
This commit is contained in:
autoscatto 2020-09-25 12:55:05 +02:00
parent b4d57b16cf
commit e489edadfb
42 changed files with 981 additions and 207 deletions

21
.editorconfig Normal file
View file

@ -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

107
.gitignore vendored
View file

@ -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/

13
AUTHORS.rst Normal file
View file

@ -0,0 +1,13 @@
=======
Credits
=======
Development Lead
----------------
* itec <itec@ventuordici.org>
Contributors
------------
None yet. Why not be the first?

8
CONTRIBUTING.rst Normal file
View file

@ -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.

8
HISTORY.rst Normal file
View file

@ -0,0 +1,8 @@
=======
History
=======
0.1.0 (2020-09-25)
------------------
* NOPE.

22
LICENSE Normal file
View file

@ -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.

11
MANIFEST.in Normal file
View file

@ -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

85
Makefile Normal file
View file

@ -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

21
README.rst Normal file
View file

@ -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

View file

@ -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))

View file

@ -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))

View file

@ -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")

1
banana.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.7 KiB

5
banana/__init__.py Normal file
View file

@ -0,0 +1,5 @@
"""Top-level package for banana."""
__author__ = """itec"""
__email__ = 'itec@ventuordici.org'
__version__ = '0.1.0'

81
banana/bananalib.py Normal file
View file

@ -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")

110
banana/cli.py Normal file
View file

@ -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()

View file

@ -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))

View file

@ -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))

View file

@ -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))

View file

@ -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))

View file

@ -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))

View file

@ -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))

20
docs/Makefile Normal file
View file

@ -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)

1
docs/authors.rst Normal file
View file

@ -0,0 +1 @@
.. include:: ../AUTHORS.rst

30
docs/banana.rst Normal file
View file

@ -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:

162
docs/conf.py Executable file
View file

@ -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'),
]

1
docs/contributing.rst Normal file
View file

@ -0,0 +1 @@
.. include:: ../CONTRIBUTING.rst

1
docs/history.rst Normal file
View file

@ -0,0 +1 @@
.. include:: ../HISTORY.rst

20
docs/index.rst Normal file
View file

@ -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`

51
docs/installation.rst Normal file
View file

@ -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

36
docs/make.bat Normal file
View file

@ -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

7
docs/modules.rst Normal file
View file

@ -0,0 +1,7 @@
banana
======
.. toctree::
:maxdepth: 4
banana

1
docs/readme.rst Normal file
View file

@ -0,0 +1 @@
.. include:: ../README.rst

16
docs/usage.rst Normal file
View file

@ -0,0 +1,16 @@
=====
Usage
=====
To use banana in a project
.. code-block:: python
from banana import bananalib
======
Script
======
Available cli scripts:

View file

@ -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))

12
requirements_dev.txt Normal file
View file

@ -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

View file

@ -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))

26
setup.cfg Normal file
View file

@ -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']

65
setup.py Normal file
View file

@ -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,
)

1
tests/__init__.py Normal file
View file

@ -0,0 +1 @@
"""Unit test package for banana."""

14
tests/test_banana.py Normal file
View file

@ -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

27
tox.ini Normal file
View file

@ -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}