Package: shmakovpn-tools
shmakovpn_toolsHistoryPACKAGE_NAME=shmakovpnPROJECT_NAME=${PACKAGE_NAME}_toolsPROJECT_DIR=~/${PROJECT_NAME}DOCS_DIR=${PROJECT_DIR}/docs
mkvirtualenvshmakovpn-p/usr/bin/python3.6
mkdir$PROJECT_DIRcd$PROJECT_DIRtouchREADME.md# configuring .gitignoretouch.gitignoreecho'# IDEs'>>.gitignoreecho'.idea/'>>.gitignoreecho''>>.gitignoreecho'# python'>>.gitignoreecho'*.pyc'>>.gitignore#* comment for vim highlightecho'__pychache__/'>>.gitignoreecho'*.egg-info/'>>.gitignore#* comment for vim hightlightecho'.eggs/'>>.gitignoreecho''>>.gitignoreecho'# Django'>>.gitignoreecho'migrations/'>>.gitignoreecho'db.sqlite3'>>.gitignoreecho'settings.py'>>.gitignoreecho'manage.py'>>.gitignoreecho''>>.gitignoreecho'# virtualenv'>>.gitignoreecho'venv/'>>.gitignoreecho''>>.gitignoreecho'# sphinx'>>.gitignoreecho'docs/build/html/'>>.gitignoreecho'docs/build/doctrees/'>>.gitignoreecho'_build/'>>.gitignoreecho'_static/'>>.gitignoreecho'_templates/'>>.gitignoreecho''>>.gitignoreecho'# codecov'>>.gitignoreecho'.coverage'>>.gitignoreecho''>>.gitignoreecho'# pytest'>>.gitignoreecho'.pytest_cache/'>>.gitignoreecho''>>.gitignoreecho'# vim swp'>>.gitignoreecho'*.swp'>>.gitignore#* comment for vim highlightecho''>>.gitignoreecho'# pytest cache'>>.gitignoreecho'.pytest_cache/'>>.gitignoreecho''>>.gitignoreecho'# build'>>.gitignoreecho'build/'>>.gitignoreecho'dist/'>>.gitignore# conguring requirements.txttouchrequirements.txt## turning vim to IDEecho'pyflakes'>>requirements.txtecho'pep8'>>requirements.txtecho'pylint'>>requirements.txtecho'ipython'>>requirements.txt## sphinxecho'sphinx'>>requirements.txtecho'sphinx-rtd-theme'>>requirements.txt## shmakovpn whatprovidesecho'whatprovides'>>requirements.txt## twine (need for uploading package to PyPI)echo'twine'>>requirements.txt# installing packagespipinstall--upgradepip
pipinstall-rrequirements.txt# configuring travis-citouch.travis.ymlecho'language: python'>>.travis.ymlecho'sudo: false'>>.travis.ymlecho'jobs:'>>.travis.ymlecho'  include:'>>.travis.ymlecho'    - name: "Python 3.6 on Linux"'>>.travis.ymlecho'      python: "3.6"'>>.travis.ymlecho'    - name: "Python 3.7 on Linux"'>>.travis.ymlecho'      python: "3.7"'>>.travis.ymlecho'    - name: "Python 3.8 on Linux"'>>.travis.ymlecho'      python: "3.8"'>>.travis.ymlecho'    - name: "Python 3.8.0 on Windows"'>>.travis.ymlecho'      os: windows'>>.travis.ymlecho'      language: shell'>>.travis.ymlecho'      before_install:'>>.travis.ymlecho'        - choco install python --version 3.8.0'>>.travis.ymlecho'        - python -m pip install --upgrade pip'>>.travis.ymlecho'      env: PATH=/c/Python38:/c/Python38/Scripts:$PATH'>>.travis.ymlecho'install:'>>.travis.ymlecho'  - pip install -r requirements.txt'>>.travis.ymlecho'  - pip install codecov'>>.travis.ymlecho'  - pip install pytest-cov'>>.travis.ymlecho"script: coverage run -m pytest$PACKAGE_NAME/tests.py">>.travis.ymlecho'after_success:'>>.travis.ymlecho'  - codecov'>>.travis.yml# creating folders and filesmkdir$PACKAGE_NAMEtouch$PACKAGE_NAME/__init__.py# we will stay this file emptytouch$PACKAGE_NAME/version.pyecho"VERSION: str = '1.1'">>$PACKAGE_NAME/version.py# creating examle moduletouch$PACKAGE_NAME/example.pyecho"def hello_world():">>$PACKAGE_NAME/example.pyecho"    print('Hello World')">>$PACKAGE_NAME/example.py# reading versionVERSION=$(cat$PACKAGE_NAME/version.py|grep'VERSION'|sed-re"s/^[^=]*=\s* '([^ #]*)'.*$/\1/")# sphinx quick startsphinx-quickstart-q-p$PROJECT_NAME-ashmakovpn-v$VERSION-r$VERSION-len--ext-autodoc--ext-intersphinx--ext-viewcode--ext-todo--sep$DOCS_DIR## change sphinx theme to sphinx_rtd_themesed-i$DOCS_DIR/source/conf.py-re"s/^html_theme = 'alabaster'/html_theme = 'sphinx_rtd_theme'/"## change importssed-i$DOCS_DIR/source/conf.py-re"s/^# import os/import os/"sed-i$DOCS_DIR/source/conf.py-re"s/^# import sys/import sys/"## configuring sys.pathsed-i$DOCS_DIR/source/conf.py-re"s/^# sys\.path\.insert\(0, os\.path\.abspath\('\.'\)\)/PACKAGE: str='$PACKAGE_NAME'\nTEMP_LABEL1/"sed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL1/SCRIPT_DIR: str = os.path.dirname(os.path.abspath(__file__))\nTEMP_LABEL2/"sed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL2/DOCS_DIR: str = os.path.dirname(SCRIPT_DIR)\nTEMP_LABEL3/"sed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL3/PROJECT_DIR: str = os.path.dirname(DOCS_DIR)\nTEMP_LABEL4/"sed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL4/PACKAGE_DIR: str = os.path.join(PROJECT_DIR, PACKAGE)\nTEMP_LABEL5/"sed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL5/sys.path.insert(0, PACKAGE_DIR)\nTEMP_LABEL6/"## configuring versionsed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL6/VERSION: str = ''\nTEMP_LABEL7/"sed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL7/with open(os.path.join(PACKAGE_DIR, 'version.py')) as version_file:\nTEMP_LABEL8/"sed-i$DOCS_DIR/source/conf.py-re"s/^TEMP_LABEL8/    exec(version_file.read())\n\n/"sed-i$DOCS_DIR/source/conf.py-re"s/^(version\s*=\s*).*/\1'$VERSION'/"#* comment for vim highlightsed-i$DOCS_DIR/source/conf.py-re"s/^(release\s*=\s*).*/\1'$VERSION'/"#* comment for vim hightlight## creating contents.rst for readthedocs.iotouch$DOCS_DIR/source/contents.rstecho".. include:: index.rst">>$DOCS_DIR/source/contents.rst## creating introduction.rsttouch$DOCS_DIR/source/introduction.rstecho"Introduction todo">>$DOCS_DIR/source/introduction.rst## adding introduction to index.rstsed-i$DOCS_DIR/source/index.rst-re"s/^(\.\. toctree::)/.. include:: introduction.rst\n\n\1/"## adding documentation (not package!) requirementstouch$DOCS_DIR/requirements.txt## adding code documentationtouch$DOCS_DIR/source/code.rstecho'Code'>>$DOCS_DIR/source/code.rstecho"====\n">>$DOCS_DIR/source/code.rstecho".. automodule:: example">>$DOCS_DIR/source/code.rstecho' :members:'>>$DOCS_DIR/source/code.rst## adding code.rst to index.rstsed-i$DOCS_DIR/source/index.rst-re's/^(   :caption: Contents:)/\1\n\n   code/'# adding licensetouchLICENSE.txtecho"Copyright$PACKAGE_NAMEshmakovpn">>LICENSE.txtecho'Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.'>>LICENSE.txt# creating manifesttouchMANIFEST.inecho'include LICENSE.txt'>>MANIFEST.inecho'include setup.cfg'>>MANIFEST.inecho'include setup.py'>>MANIFEST.inecho'include makedoc.py'>>MANIFEST.inecho'include build_package.py'>>MANIFEST.inecho''>>MANIFEST.inecho'recursive-include test *'>>MANIFEST.in#* comment for vim highlightecho'recursive-include docs *'>>MANIFEST.in#* comment for vim highlightecho''>>MANIFEST.inecho'recursive-exclude docs/build *'>>MANIFEST.in#* comment for vim highlightecho'recursive-exclude * __pycache__'>>MANIFEST.in#* comment for vim highlightecho'recursive-exclude * *.py[co]'>>MANIFEST.inecho'recursive-exclude .git *'>>MANIFEST.in#* comment for vim highlightecho'recursive-exclude .idea *'>>MANIFEST.in#* comment for vim highlightecho'recursive-exclude venv *'>>MANIFEST.in#* comment for vim highlight# creating setup.cfgtouchsetup.cfgecho'[build_sphinx]'>>setup.cfgecho'source-dir = docs/'>>setup.cfgecho'build-dir = docs/build'>>setup.cfgecho'all_files = 1'>>setup.cfgecho''>>setup.cfgecho'[metadata]'>>setup.cfgecho'license_file = LICENSE.txt'>>setup.cfg# creating setup.pytouchsetup.pyecho"import os">>setup.pyecho"from setuptools import setup, find_packages">>setup.pyecho"from${PACKAGE_NAME}.version import VERSION">>setup.pyecho"">>setup.pyecho"SCRIPT_DIR: str = os.path.dirname(os.path.abspath(__file__))">>setup.pyecho"os.chdir(SCRIPT_DIR)">>setup.pyecho"">>setup.pyecho"with open('README.md') as f:">>setup.pyecho"    long_description: str = f.read()">>setup.pyecho"">>setup.pyecho"setup(">>setup.pyecho"    name='$PROJECT_NAME',">>setup.pyecho"    version=VERSION,">>setup.pyecho"    packages=find_packages(),">>setup.pyecho"    author='shmakovpn',">>setup.pyecho"    author_email='shmakovpn@yandex.ru',">>setup.pyecho"    url='https://github.com/shmakovpn/$PROJECT_NAME',">>setup.pyecho"    download_url='https://github.com/shmakovpn/$PROJECT_NAME/archive/%s.zip' % (VERSION, ),">>setup.pyecho"    long_description=long_description,">>setup.pyecho"    long_description_content_type='text/markdown',">>setup.pyecho"    entry_points={">>setup.py#echo "        'console_scripts': ['$PACKAGE_NAME=$PACKAGE_NAME:main']," >> setup.pyecho"    },">>setup.pyecho"    install_requires=[">>setup.py#echo "        'chardet'," >> setup.pyecho"    ],">>setup.pyecho"    include_package_data=True,">>setup.pyecho"    test_suite='$PACKAGE_NAME.tests',">>setup.pyecho"    python_requires='>=3.6',">>setup.pyecho"    classifiers=[">>setup.pyecho"        'Programming Language :: Python :: 3',">>setup.py#echo "        'Environment :: Console'," >> setup.pyecho"        'License :: OSI Approved :: Apache Software License',">>setup.pyecho"        'Operating System :: OS Independent',">>setup.pyecho"    ],">>setup.pyecho")">>setup.py# creating build_package.py, script that runs *python setup.py sdist bdist_wheel*touchbuild_package.pyecho"import os">>build_package.pyecho"SCRIPT_DIR: str = os.path.dirname(os.path.abspath(__file__))">>build_package.pyecho"">>build_package.pyecho"">>build_package.pyecho"def run_build():">>build_package.pyecho"    os.chdir(SCRIPT_DIR)">>build_package.pyecho"    os.system('python setup.py test')">>build_package.pyecho"    os.system('python setup.py sdist bdist_wheel')">>build_package.pyecho"    print('__END__')">>build_package.pyecho"">>build_package.pyecho"">>build_package.pyecho"if __name__ == '__main__':">>build_package.pyecho"    run_build()">>build_package.py# creating makedoc.py, script that runs *sphinx-build*touchmakedoc.pyecho"import os">>makedoc.pyecho"SCRIPT_DIR: str = os.path.dirname(os.path.abspath(__file__))">>makedoc.pyecho"">>makedoc.pyecho"">>makedoc.pyecho"def run_sphinx():">>makedoc.pyecho"    docs_dir: str = os.path.join(SCRIPT_DIR, 'docs')">>makedoc.pyecho"    docs_source_dir: str = os.path.join(docs_dir, 'source')">>makedoc.pyecho"    build_dir: str = os.path.join(docs_dir, 'build')">>makedoc.pyecho"    html_dir: str = os.path.join(build_dir, 'html')">>makedoc.pyecho"    os.system('sphinx-build -b html \"%s\" \"%s\"' % (docs_source_dir, html_dir))">>makedoc.pyecho"    print('__END__')">>makedoc.pyecho"">>makedoc.pyecho"">>makedoc.pyecho"if __name__ == '__main__':">>makedoc.pyecho"    run_sphinx()">>makedoc.py# creating upload_pypi.pytouchupload_pypi.pyecho"import os">>upload_pypi.pyecho"import subprocess">>upload_pypi.pyecho"from typing import List">>upload_pypi.pyecho"from${PACKAGE_NAME}.version import VERSION">>upload_pypi.pyecho"">>upload_pypi.pyecho"SCRIPT_DIR: str = os.path.dirname(os.path.abspath(__file__))">>upload_pypi.pyecho"">>upload_pypi.pyecho"">>upload_pypi.pyecho"def get_pip_config():">>upload_pypi.pyecho"    process: subprocess.Popen = subprocess.Popen(">>upload_pypi.pyecho"        ['pip', 'config', 'list', ], stdout=subprocess.PIPE, stderr=subprocess.PIPE">>upload_pypi.pyecho"    )">>upload_pypi.pyecho"    process.wait()">>upload_pypi.pyecho"    if not process.returncode:">>upload_pypi.pyecho"        if process.stdout.readable():">>upload_pypi.pyecho"            return list(map(lambda x: x.decode().rstrip(), process.stdout.readlines()))">>upload_pypi.pyecho"        else:">>upload_pypi.pyecho"            return []  # pip configuration is empty">>upload_pypi.pyecho"    else:">>upload_pypi.pyecho"        if process.stdout.readable():">>upload_pypi.pyecho"            print(process.stdout.read().decode())">>upload_pypi.pyecho"        if process.stderr.readable():">>upload_pypi.pyecho"            print(process.stderr.read().decode())">>upload_pypi.pyecho"        exit(1)">>upload_pypi.pyecho"">>upload_pypi.pyecho"">>upload_pypi.pyecho"def run_upload():">>upload_pypi.pyecho"    pip_certs: List[str] = list(filter(lambda x: str(x).startswith('global.cert='), get_pip_config()))">>upload_pypi.pyecho"    if pip_certs:">>upload_pypi.pyecho"        pip_cert_arg: str = '--cert %s ' % (pip_certs[0].split('=')[1])">>upload_pypi.pyecho"    else:">>upload_pypi.pyecho"        pip_cert_arg: str = ''">>upload_pypi.pyecho"    print(pip_cert_arg)">>upload_pypi.pyecho"    dist_dir: str = os.path.join(SCRIPT_DIR, 'dist')">>upload_pypi.pyecho"    dist_file: str = os.path.join(dist_dir, '${PACKAGE_NAME}-%s.tar.gz' % (VERSION, ))">>upload_pypi.pyecho"    dist_whls: str = os.path.join(dist_dir, '${PACKAGE_NAME}-%s-*.whl' % (VERSION, ))">>upload_pypi.py#* comment for vim highlightecho"    os.system('twine upload \"%s\" \"%s\" %s --verbose' % (dist_file, dist_whls, pip_cert_arg))">>upload_pypi.pyecho"    print('__end__')">>upload_pypi.pyecho"">>upload_pypi.pyecho"">>upload_pypi.pyecho"if __name__ == '__main__':">>upload_pypi.pyecho"    run_upload()">>upload_pypi.py# creating tests.pytouch$PACKAGE_NAME/tests.pyecho"import unittest">>$PACKAGE_NAME/tests.py