redesigned python structure

This commit is contained in:
2021-10-13 17:50:17 +02:00
parent 0b03819d40
commit d9491491c1
16 changed files with 46 additions and 148 deletions
@@ -1 +0,0 @@
@@ -1,3 +0,0 @@
from .cli import main
main()
@@ -1,3 +0,0 @@
VERSION = (1, 0, 0)
__version__ = '.'.join(map(str, VERSION))
@@ -1,12 +0,0 @@
from argparse import ArgumentParser
def main():
parser = ArgumentParser(prog='cli')
parser.add_argument('name', help="The user's name.")
args = parser.parse_args()
print("Hello, %s!" % args.name)
if __name__ == '__main__':
main()
@@ -0,0 +1,9 @@
from .helpers import get_fib_sequence
#Function to calculate square root of the given nth fib number
def power_fib_number(number,power):
print("retrieving nth of Fibonacci sequence...")
number = get_fib_sequence(number)
print("calculating power n of given number...")
return number ** power
@@ -0,0 +1,13 @@
# Function to get the nth number of Fibonacci sequence
# 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
def get_fib_sequence(fib_numbers):
if fib_numbers < 0:
print("output is incorrect")
elif fib_numbers == 0:
return 0
elif fib_numbers == 1 or fib_numbers == 2:
return 1
else:
return get_fib_sequence(fib_numbers - 1) + get_fib_sequence(fib_numbers - 2)
print("file accessed")
@@ -1,9 +1,2 @@
certifi==2018.1.18
chardet==3.0.4
idna==2.6
pkginfo==1.4.1
requests==2.21.0
requests-toolbelt==0.8.0
tqdm==4.19.7
twine==1.10.0
urllib3==1.24.2
pandas
numpy
@@ -1,4 +0,0 @@
from app.cli import main
if __name__ == '__main__':
main()
@@ -1,108 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Note: To use the 'upload' functionality of this file, you must install Twine:
# $ pip install -r requirements.txt
import io
import os
import sys
from shutil import rmtree
from setuptools import find_packages, setup, Command
# Package meta-data.
NAME = 'mypackage'
DESCRIPTION = 'My short description for my project.'
URL = 'https://github.com/me/myproject'
EMAIL = 'me@example.com'
AUTHOR = 'Awesome Soul'
REQUIRES_PYTHON = '>=3.6.0'
VERSION = None
LICENSE = 'MIT'
# What packages are required for this module to be executed?
REQUIRED = [
# 'requests', 'maya', 'records',
]
here = os.path.abspath(os.path.dirname(__file__))
with io.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = '\n' + f.read()
about = {}
if not VERSION:
with open(os.path.join(here, NAME, '__version__.py')) as f:
exec(f.read(), about)
else:
about['__version__'] = VERSION
class UploadCommand(Command):
"""Support setup.py upload."""
description = 'Build and publish the package.'
user_options = []
@staticmethod
def status(s):
"""Prints things in bold."""
print('\033[1m{0}\033[0m'.format(s))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
self.status('Removing previous builds…')
rmtree(os.path.join(here, 'dist'))
except OSError:
pass
self.status('Building Source and Wheel (universal) distribution…')
os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
self.status('Uploading the package to PyPi via Twine…')
os.system('twine upload dist/*')
self.status('Pushing git tags…')
os.system('git tag v{0}'.format(about['__version__']))
os.system('git push --tags')
sys.exit()
setup(
name=NAME,
version=about['__version__'],
description=DESCRIPTION,
long_description=long_description,
author=AUTHOR,
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
py_modules=['mypackage'],
entry_points={
'console_scripts': ['app=cli:main'],
},
install_requires=REQUIRED,
include_package_data=True,
license=LICENSE,
classifiers=[
# Trove classifiers
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy'
],
# $ setup.py publish support.
cmdclass={
'upload': UploadCommand,
},
)
@@ -0,0 +1,11 @@
import unittest
from package.core import *
class BasicTestSuite(unittest.TestCase):
def test_power_function(self):
print("running power function test")
self.assertEqual(power_fib_number(6,2), 64, "should be 64")
if __name__ == '__main__':
unittest.main()
@@ -0,0 +1,11 @@
import unittest
from package.helpers import get_fib_sequence
class BasicTestSuite(unittest.TestCase):
def test_fib_function(self):
print("running fibo function test")
self.assertEqual(get_fib_sequence(12), 142, "should be 144")
if __name__ == '__main__':
unittest.main()
@@ -1,8 +0,0 @@
import unittest
class ApplicationTests(unittest.TestCase):
def test_hello(self):
self.assertTrue(True)