Начало

This commit is contained in:
Andrei Astafev 2019-07-03 19:14:35 +03:00
commit 551b0d653a
9 changed files with 115 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
build
dist
*.egg-info
__pycache__
*.e4p
py3x.zip

9
Makefile Normal file
View File

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

19
README.rst Normal file
View File

@ -0,0 +1,19 @@
Пример модуля на Python3
========================
Варианты запуска:
.. code:: shell
./py3x.py
или
.. code:: shell
python3 -m py3x
или
.. code:: shell
make zip
python3 py3x.zip

5
__main__.py Normal file
View File

@ -0,0 +1,5 @@
print("loading __main__.py")
from py3x import main
main()

7
py3x.py Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python3
print("loading file py3x.py")
from py3x import main
main()

9
py3x/__init__.py Normal file
View File

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

6
py3x/__main__.py Normal file
View File

@ -0,0 +1,6 @@
print("loading py3x/__main__.py")
from py3x import main
main()

27
py3x/functions.py Normal file
View File

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

26
setup.py Normal file
View File

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