commit 551b0d653aa6c45a2be274fb34e0650231b0c666 Author: Andrey Astafyev Date: Wed Jul 3 19:14:35 2019 +0300 Начало diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..725dc94 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +build +dist +*.egg-info +__pycache__ +*.e4p +py3x.zip + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fe25d61 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +all: + python3 setup.py build + +clean: + rm -rf dist build py3x.egg-info + +zip: + zip -r py3x * -i *.py py3x/*.py + diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..84f99ba --- /dev/null +++ b/README.rst @@ -0,0 +1,19 @@ +Пример модуля на Python3 +======================== + +Варианты запуска: + +.. code:: shell + ./py3x.py + +или + +.. code:: shell + python3 -m py3x + +или + +.. code:: shell + make zip + python3 py3x.zip + diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000..d0ca832 --- /dev/null +++ b/__main__.py @@ -0,0 +1,5 @@ +print("loading __main__.py") + +from py3x import main + +main() diff --git a/py3x.py b/py3x.py new file mode 100755 index 0000000..3722be4 --- /dev/null +++ b/py3x.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +print("loading file py3x.py") + +from py3x import main + +main() diff --git a/py3x/__init__.py b/py3x/__init__.py new file mode 100644 index 0000000..ced3179 --- /dev/null +++ b/py3x/__init__.py @@ -0,0 +1,9 @@ +print("loading py3x/__init__.py") + +from py3x.functions import parse_args + +def main(): + """ Main function """ + print("running function main from py3x/__init__.py") + parse_args() + diff --git a/py3x/__main__.py b/py3x/__main__.py new file mode 100644 index 0000000..d82b90e --- /dev/null +++ b/py3x/__main__.py @@ -0,0 +1,6 @@ +print("loading py3x/__main__.py") + +from py3x import main + +main() + diff --git a/py3x/functions.py b/py3x/functions.py new file mode 100644 index 0000000..1981020 --- /dev/null +++ b/py3x/functions.py @@ -0,0 +1,27 @@ +print("loading py3x/functions.py") + +import argparse + +def parse_args(): + """ Parse command line arguments """ + print("running function parse_args from py3x/functions.py") + + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--input", + help="Input file name") + parser.add_argument("-o", "--output", + help="Output file name") + parser.add_argument("-v", "--verbose", action="store_true", + help="Increase output verbosity") + args = parser.parse_args() + if args.verbose: + if args.input: + print("input file name is: {}".format(args.input)) + if args.output: + print("output file name is: {}".format(args.output)) + else: + if args.input: + print(args.input) + if args.output: + print(args.output) + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..813d4ee --- /dev/null +++ b/setup.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +from setuptools import setup, find_packages + +with open('README.rst') as f: + readme = f.read() + +setup( + name='py3x', + version='0.1.2', + description='Sample package for Python3', + long_description=readme, + author='Andrei Astafev', + author_email='dev@246060.ru', + url='https://dsp.246060.ru', + + packages=[ + 'py3x', + ], + + entry_points={ + 'console_scripts': [ + 'py3x = py3x:main', + ], + }, +)