From e99384c74acedcf1998fc6d06352ee849f8ffe13 Mon Sep 17 00:00:00 2001 From: bitranox Date: Thu, 23 Jul 2020 20:12:28 +0200 Subject: [PATCH 1/3] refractor --- .docs/README_template.rst | 2 +- CHANGES.rst | 6 ++++++ README.rst | 8 +++++++- rst_include/__init__conf__.py | 4 ++-- setup.py | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.docs/README_template.rst b/.docs/README_template.rst index 0ec5650..fd78af7 100644 --- a/.docs/README_template.rst +++ b/.docs/README_template.rst @@ -1,4 +1,4 @@ -Version 2.0.4 as of 2020-07-23, see changelog_ +Version 2.0.5a0 as of 2020-07-23, see changelog_ ======================================================= diff --git a/CHANGES.rst b/CHANGES.rst index 780b920..bb32ba1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,12 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes + +2.0.5a0 +------- +2020-07-23: development + - + 2.0.4 ----- 2020-07-23: patch release diff --git a/README.rst b/README.rst index 30b305b..16a078c 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Version 2.0.4 as of 2020-07-23, see changelog_ +Version 2.0.5a0 as of 2020-07-23, see changelog_ ======================================================= @@ -492,6 +492,12 @@ Changelog - new MINOR version for added functionality in a backwards compatible manner - new PATCH version for backwards compatible bug fixes + +2.0.5a0 +------- +2020-07-23: development + - + 2.0.4 ----- 2020-07-23: patch release diff --git a/rst_include/__init__conf__.py b/rst_include/__init__conf__.py index 38b49da..d5ca9c3 100644 --- a/rst_include/__init__conf__.py +++ b/rst_include/__init__conf__.py @@ -1,6 +1,6 @@ name = 'rst_include' title = 'commandline tool to resolve RST File includes' -version = '2.0.4' +version = '2.0.5a0' url = 'https://github.com/bitranox/rst_include' author = 'Robert Nowotny' author_email = 'bitranox@gmail.com' @@ -14,7 +14,7 @@ def print_info() -> None: commandline tool to resolve RST File includes - Version : 2.0.4 + Version : 2.0.5a0 Url : https://github.com/bitranox/rst_include Author : Robert Nowotny Email : bitranox@gmail.com""") diff --git a/setup.py b/setup.py index 3f4135f..2d72aa9 100644 --- a/setup.py +++ b/setup.py @@ -83,7 +83,7 @@ def get_line_data(line: str) -> str: setup_kwargs: Dict[str, Any] = dict() setup_kwargs['name'] = 'rst_include' -setup_kwargs['version'] = '2.0.4' +setup_kwargs['version'] = '2.0.5a0' setup_kwargs['url'] = 'https://github.com/bitranox/rst_include' setup_kwargs['packages'] = find_packages() setup_kwargs['package_data'] = {'rst_include': ['py.typed', '*.pyi', '__init__.pyi']} From b0ead725887e408f5f4bc007768ac35477e9f913 Mon Sep 17 00:00:00 2001 From: bitranox Date: Wed, 29 Jul 2020 17:32:40 +0200 Subject: [PATCH 2/3] refractor --- .docs/README_template.rst | 10 +- .docs/index.rst | 2 +- .travis.yml | 185 +++++------------ CHANGES.rst | 7 +- README.rst | 190 +++++++++--------- pytest.ini | 1 - requirements.txt | 1 + rst_include/__init__conf__.py | 4 +- rst_include/cli_exit_tools.py | 143 ------------- rst_include/rst_include_cli.py | 12 +- setup.py | 2 +- travis_secrets/create_secrets.sh | 2 +- .../secrets/PYPI_PASSWORD.secret.txt | 1 + .../secrets/pypi_password.secret.txt | 1 - 14 files changed, 167 insertions(+), 394 deletions(-) delete mode 100644 rst_include/cli_exit_tools.py create mode 100644 travis_secrets/secrets/PYPI_PASSWORD.secret.txt delete mode 100644 travis_secrets/secrets/pypi_password.secret.txt diff --git a/.docs/README_template.rst b/.docs/README_template.rst index fd78af7..a2c91f3 100644 --- a/.docs/README_template.rst +++ b/.docs/README_template.rst @@ -1,4 +1,4 @@ -Version 2.0.5a0 as of 2020-07-23, see changelog_ +Version 2.0.5 as of 2020-07-29, see changelog_ ======================================================= @@ -26,10 +26,6 @@ Python version required: 3.6.0 or newer -Installation and Upgrade ------------------------- -.. include:: ./installation.rst - Usage ----------- .. include:: ./usage.rst @@ -38,6 +34,10 @@ Usage from Commandline ------------------------ .. include:: ./commandline_help.rst +Installation and Upgrade +------------------------ +.. include:: ./installation.rst + Requirements ------------ following modules will be automatically installed : diff --git a/.docs/index.rst b/.docs/index.rst index 1c81650..16de106 100644 --- a/.docs/index.rst +++ b/.docs/index.rst @@ -1,6 +1,6 @@ -- `Installation and Upgrade`_ - `Usage`_ - `Usage from Commandline`_ +- `Installation and Upgrade`_ - `Requirements`_ - `Acknowledgements`_ - `Contribute`_ diff --git a/.travis.yml b/.travis.yml index e377e9d..112a7c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,23 @@ sudo: true env: global: - - cPREFIX="" # prefix before commands - used for wine, there the prefix is "wine" - - cPYTHON="python" # command to launch python interpreter (its different on macOs, there we need python3) - - cPIP="python -m pip" # command to launch pip (its different on macOs, there we need pip3) - - WINEDEBUG=fixme-all # switch off wine fix me messages + # prefix before commands - used for wine, there the prefix is "wine" + - cPREFIX="" + # command to launch python interpreter (its different on macOs, there we need python3) + - cPYTHON="python" + # command to launch pip (its different on macOs, there we need pip3) + - cPIP="python -m pip" + # switch off wine fix me messages + - WINEDEBUG=fixme-all + # the registered CLI Command + - CLI_COMMAND=rst_include + # the source file for rst_include (rebuild rst file includes) + - RST_INCLUDE_SOURCE="./.docs/README_template.rst" + # the target file for rst_include (rebuild rst file includes) + - RST_INCLUDE_TARGET="./README.rst" + # secure environment variable - secure: "Qe9oava9KsQAqDpYwKl3s51ZZTj6j1aZw+vrSJYz8GXanGGGVfoe1FLDjm9TyQTMDkiQd4HF0zKAbUGfgR3DKpfg17BgWZn9r8qt4WE4GclO0h3cXnqp7F3DmZqIBDyZfOgXalng51/g02G78rCeugA7jZ+pPFEzkPkmuhWrsalnsVKUpxxmsaBWCP8jftUTXbnuu7xB6RZPmd8Vz9eYbEwujES1cAo/Yz79crJfBIw3jYkU8GYGEVt9QojBTZXieD6WN6wexRzLRChzn32SDfhT6NQVKOqjNBItRXqJd8luwLbon6k63lyvA5VNNgA70Roa4SpsDwxmqeGLone2Y5WXXKcZgIxQcMVzxJMDYGNEtGX5rGuwOU1Fn6JM1LBC9AW79y1dusyAJJHumPa0f5FknIiUvIdJ5sz/emS/tuoSKtf12vSeXvQskZ2m/Fe5HWSym+qeOuNHqvmOcN+s2aiNFMTQWWxuhyN5o96AeDvn6eF8fpbQqTD1nSwzlZ13BZzB8FtokCU1ASxhqL9e0H6fXOWg8MjXFzgYYW5R6nx31CGOCSWUPWxX5Y2NfdJi9PCMZLOPMbWw0jOO6P3Fw2TuCxQGuAfSWuxMrWHFfrQpfG3eoaYYluzUKA9z2rAy7O9l7tu9dSSfl6IEmLi/dLnBKEIerNKNQpN1xWd8lAQ=" # CC_TEST_REPORTER_ID.secret - - secure: "jNc+2qZfnAIzMh4rUshJCDzjADSSZr+AsX3xA5W5tnLVBBHGu0aKsmify/biKWKe67n+hvJyXWWnchtEEulvZR66TQ0VLDSXTVO5JDx2nTakff5nPRkveayxDFE/H6Xz5wdg8o3G1NcKHQWSDojaQWPRTb3KivQ3Xr4aydEX/i3PqEgSGHg2tT/DbGmFbA9e0EILH28aPx4v9CnvkvpH1R7Qzy3BzaIFVVcj5kKHV9iPzDxvGDRfHha6EQSS2ScWUnyT4fWSHi7aIcpKL4lYSBxHVOHOSIuBbFRIvwP2J1zrS1tQL7VP21V5x7XsI8kIzTZ4DP7UR5+gXOELJ66CpHOR3Kvf6DLw6sc5AV1bpr63g/pqXPk9lQOWa2pK12sX4Zk8JwNr649t930wC0vCIPYQ1sXdx2K+4YRmflMi5RDC0NRM1e+obYOsaKtwzbNsBKJ0ngjcHXYsLt0Wessqeq+SwU4+l/pIFBQup3Waaa2lTT3Y7dShNyNfQebAq2VSCa0vY/UqiTNk+ucf2xlR6thIlj1aiOXSyxeiPsD3GP0wkb1BGpEGS54UULf91RA0zXz2pYxVnw1x4ptlW3nTPqHEmOB55sGtxb/ek4jRDtcqlIw2SojjWfWk56VazEEE6gsHN+xX2ooXi+zsWn4+5xXqyBkzzZseJJCb3qBXAVI=" # pypi_password.secret + - secure: "DrfW5T9mXVPBREpmvqHm/lGeNINRXo7aCFXiW5RVGoyFR2GsdZuF8GQQX9SFBGm46bgQ9cuCQErEkwxxa5nBIXbfEIpn4TMDZ/JSbS7zWk4WT6VSuRXl2ibiKfZP53mR/+AAdJvoSY72JlDr6q1p/M9AMj816n5mvanDmebUQNiUHIksuRZR3I2RBAHj3aWb1AOYSg6WIMZernacamSnY4KCodYL5FXxjASHuyxP2vtU+tgrLmUxRtFX5zvPFAMv/0372cS/QSizwnuYbX2MU8UFuxsrBZISGuUtehItJ7/aYjhFzYN8CKad90OFqQNwQ+Tbd828vxq3kbKByVrZqbh5eJGDGBfZobFxOyEXIqfNcwVrVE5XDVbY6+BTu+YMXCJe/scHL6nxkKM8vs32LgofHo4RChY9HG8IHPzN2hgwohivBCnmzh4MpArfOXpAVXhhpioFcvKpaigiX35c1+Z4S3tdz6ERyzCox+tVAlZs5gUgNsU+ZVUbquHSRSo3+e+fAfc7NqZs+VjzIApUbxGHYn2GMSACuIwQLKOrNsWlAvJZ0BalstVyDEXESRjDwx0Z45WP88MjXUFVJIfFHMJzu0OtGPFY3QGIZIgxiZMei3/D0c8dU0gyMLZuwJZGHCkchTKTo6ZgdsNGnf+e3x3J0VyXHTENT0GuyYhKN88=" # PYPI_PASSWORD.secret addons: @@ -46,45 +57,50 @@ matrix: language: python python: "3.6" before_install: - - export mypy_strict_typecheck="True" - - export build_docs="False" - - export deploy_on_pypi="False" + - export MYPY_STRICT="True" + - export BUILD_DOCS="False" + - export DEPLOY_CHECK="False" + - export DEPLOY="False" - os: linux language: python python: "3.7" before_install: - - export mypy_strict_typecheck="True" - - export build_docs="False" - - export deploy_on_pypi="False" + - export MYPY_STRICT="True" + - export BUILD_DOCS="False" + - export DEPLOY_CHECK="False" + - export DEPLOY="False" - os: linux language: python python: "3.8" before_install: - - export mypy_strict_typecheck="True" - - export build_docs="True" - - export deploy_on_pypi="True" + - export MYPY_STRICT="True" + - export BUILD_DOCS="True" + - export DEPLOY_CHECK="True" + - export DEPLOY="True" - os: linux language: python python: "3.8-dev" before_install: - - export mypy_strict_typecheck="True" - - export build_docs="False" - - export deploy_on_pypi="False" + - export MYPY_STRICT="True" + - export BUILD_DOCS="False" + - export DEPLOY_CHECK="False" + - export DEPLOY="False" - os: linux language: python python: "pypy3" before_install: - - export mypy_strict_typecheck="True" - - export build_docs="False" - - export deploy_on_pypi="False" + - export MYPY_STRICT="False" + - export BUILD_DOCS="False" + - export DEPLOY_CHECK="False" + - export DEPLOY="False" - os: osx @@ -100,130 +116,23 @@ matrix: install: - # install lib_bash_wine - this installs also lib_bash - - $(command -v sudo 2>/dev/null) git clone https://github.com/bitranox/lib_bash_wine.git /usr/local/lib_bash_wine - - $(command -v sudo 2>/dev/null) chmod -R 0755 /usr/local/lib_bash_wine - - $(command -v sudo 2>/dev/null) chmod -R +x /usr/local/lib_bash_wine/*.sh - - $(command -v sudo 2>/dev/null) /usr/local/lib_bash_wine/install_or_update.sh - - export lib_bash_color="/usr/local/lib_bash/lib_color.sh" - - export lib_bash_banner="/usr/local/lib_bash/lib_helpers.sh banner" - - export lib_bash_banner_warning="/usr/local/lib_bash/lib_helpers.sh banner_warning" - - export lib_bash_wine="/usr/local/lib_bash_wine" - - ${lib_bash_banner} "upgrading pip"; ${cPREFIX} ${cPIP} install --upgrade pip - - ${lib_bash_banner} "upgrading setuptools"; ${cPREFIX} ${cPIP} install --upgrade setuptools - - ${lib_bash_banner} "upgrading wheel"; ${cPREFIX} ${cPIP} install --upgrade wheel - - ${lib_bash_banner} "upgrading pytest-pycodestyle"; ${cPREFIX} ${cPIP} install --upgrade "pytest-pycodestyle; python_version >= \"3.5\"" - - ${lib_bash_banner} "installing lib_log_utils"; ${cPREFIX} ${cPIP} install git+https://github.com/bitranox/lib_log_utils.git - - if [[ ${build_docs} == "True" ]]; then - ${lib_bash_banner} "installing rst_include"; ${cPREFIX} ${cPIP} install git+https://github.com/bitranox/rst_include.git; - fi - - - if [[ ${cPREFIX} == "wine" ]]; then ${lib_bash_wine}/001_000_install_wine.sh ; fi - - if [[ ${cPREFIX} == "wine" ]]; then ${lib_bash_wine}/002_000_install_wine_machine.sh ; fi - - if [[ ${wine_python_version} == "python3" ]]; then ${lib_bash_wine}/003_000_install_wine_python3_preinstalled.sh ; fi - - if [[ ${cPREFIX} == "wine" ]]; then ${lib_bash_wine}/004_000_install_wine_git_portable.sh ; fi - - if [[ ${cPREFIX} == "wine" ]]; then ${lib_bash_wine}/005_000_install_wine_powershell_core.sh ; fi + - ${cPIP} install lib_travis + - log_util --colortest + - lib_travis install script: - - # setup.py test - - COMMAND="${cPREFIX} ${cPYTHON} ./setup.py test" - - ${lib_bash_banner} "running '${COMMAND}'" - - if ${COMMAND}; then ${lib_bash_banner} "'${COMMAND}' - OK"; else ${lib_bash_banner_warning} "'${COMMAND}' - FAILED" && exit 1; fi - - # pip install git+https://github.com/bitranox/rst_include.git --install-option test - - COMMAND="${cPREFIX} ${cPIP} install git+https://github.com/bitranox/rst_include.git --install-option test" - - ${lib_bash_banner} "running '${COMMAND}'" - - if ${COMMAND}; then ${lib_bash_banner} "'${COMMAND}' - OK"; else ${lib_bash_banner_warning} "'${COMMAND}' - FAILED" && exit 1; fi - - # pip install git+https://github.com/bitranox/rst_include.git - - COMMAND="${cPREFIX} ${cPIP} install git+https://github.com/bitranox/rst_include.git" - - ${lib_bash_banner} "running '${COMMAND}'" - - if ${COMMAND}; then ${lib_bash_banner} "'${COMMAND}' - OK"; else ${lib_bash_banner_warning} "'${COMMAND}' - FAILED" && exit 1; fi - - # commandline registration check - - COMMAND="${cPREFIX} rst_include --version" - - ${lib_bash_banner} "running '${COMMAND}' (check commandline registration)" - - if ${COMMAND}; then ${lib_bash_banner} "'${COMMAND}' - OK"; else ${lib_bash_banner_warning} "'${COMMAND}' - FAILED" && exit 1; fi - - # pytest codecov only - - COMMAND="${cPREFIX} ${cPYTHON} -m pytest --cov=rst_include" - - ${lib_bash_banner} "running '${COMMAND}' - (coverage only)" - - ${cPREFIX} ${cPIP} install --upgrade -r ./requirements_test.txt > /dev/null 2>&1 - - ${cPREFIX} ${cPIP} install --upgrade codecov > /dev/null 2>&1 - - ${cPREFIX} ${cPIP} install --upgrade pytest-cov > /dev/null 2>&1 - - if ${COMMAND}; then ${lib_bash_banner} "'${COMMAND}' - OK"; else ${lib_bash_banner_warning} "'${COMMAND}' - FAILED" && exit 1; fi - - # mypy typecheck strict - - if [[ ${mypy_strict_typecheck} == "True" ]]; then - COMMAND="${cPREFIX} ${cPYTHON} -m mypy -p rst_include --strict --no-warn-unused-ignores --implicit-reexport --follow-imports=silent" - ${lib_bash_banner} "running '${COMMAND}'"; - if ${COMMAND}; then ${lib_bash_banner} "'${COMMAND}' - OK"; else ${lib_bash_banner_warning} "'${COMMAND}' - FAILED" && exit 1; fi - else - ${lib_bash_banner_warning} "mypy typecheck --strict disabled on this build"; - fi - - # Bild Docs - - if [[ "${build_docs}" == "True" ]]; then - COMMAND="${cPREFIX}" rst_include include "./.docs/README_template.rst" "./README.rst"; - ${lib_bash_banner} "running '${COMMAND}' - rebuild README.rst"; - if ${COMMAND}; then ${lib_bash_banner} "'${COMMAND}' - OK"; else ${lib_bash_banner_warning} "'${COMMAND}' - FAILED" && exit 1; fi - else - ${lib_bash_banner_warning} "rebuild README.rst disabled on this build" ; - fi - - # Check if Deployment would work on non-tagged builds - - if [[ -f setup.py ]] && [[ -z ${TRAVIS_TAG} ]] && [[ ${build_docs} == "True" ]]; then - ${lib_bash_banner} "Testing PyPi Deployment"; - ${cPREFIX} ${cPIP} install readme_renderer > /dev/null 2>&1; - ${cPREFIX} ${cPIP} install --upgrade twine > /dev/null 2>&1; - ${cPREFIX} ${cPIP} install wheel > /dev/null 2>&1; - ${cPREFIX} ${cPYTHON} setup.py sdist bdist_wheel || ${lib_bash_banner_warning} "Building Wheels failed" 1>&2; - if ${cPREFIX} twine check dist/*; then - ${lib_bash_banner} "PyPi Deployment would be OK"; - else - ${lib_bash_banner_warning} "PyPi Deployment would fail"; - exit 1; - fi - else - ${lib_bash_banner_warning} "Check PyPi Deployment disabled on this build" ; - fi + - BRANCH=$(lib_travis get_branch) + - log_util --level=NOTICE --banner "working on branch ${BRANCH}" + - lib_travis script after_success: - - ${cPREFIX} coverage report - - ${cPREFIX} codecov - # codeclimate coverage upload - TODO: check function on wine - - if [ "${TRAVIS_OS_NAME}" == 'windows' ]; then - CODECLIMATE_REPO_TOKEN="${CC_TEST_REPORTER_ID}"; - ${cPREFIX} ${cPIP} install codeclimate-test-reporter; - ${cPREFIX} codeclimate-test-reporter; - else - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter; - chmod +x ./cc-test-reporter; - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; - fi - - # This works for sure - the Travis deploy is somehow buggy. - # create the secret : - # pypi_password - # to create the secret : - # cd / - # sudo travis encrypt -r / pypi_password=***** - # copy and paste the encrypted password in the PizzaCutter Config File - - if [[ ${deploy_on_pypi} == "True" ]] && [[ -n ${TRAVIS_TAG} ]]; then - ${lib_bash_banner} "Deploy on PyPi"; - export travis_deploy="True"; - ${cPREFIX} ${cPIP} install readme_renderer; - ${cPREFIX} ${cPIP} install --upgrade twine; - ${cPREFIX} ${cPIP} install wheel; - ${cPREFIX} ${cPYTHON} setup.py sdist bdist_wheel; - ${cPREFIX} twine check dist/*; - ${cPREFIX} twine upload --repository-url https://upload.pypi.org/legacy/ -u bitranox -p ${pypi_password} dist/*; - fi + - lib_travis after_success + - lib_travis deploy notifications: email: recipients: - bitranox@gmail.com - on_success: never # default: change - on_failure: always # default: always + # on_success default: change + on_success: never + on_failure: always diff --git a/CHANGES.rst b/CHANGES.rst index bb32ba1..3c6f5e6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,10 +6,11 @@ Changelog - new PATCH version for backwards compatible bug fixes -2.0.5a0 +2.0.5 ------- -2020-07-23: development - - +2020-07-29: feature release + - use the new pizzacutter template + - use cli_exit_tools 2.0.4 ----- diff --git a/README.rst b/README.rst index 16a078c..78c144d 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Version 2.0.5a0 as of 2020-07-23, see changelog_ +Version 2.0.5 as of 2020-07-29, see changelog_ ======================================================= @@ -74,9 +74,9 @@ tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 ---- -- `Installation and Upgrade`_ - `Usage`_ - `Usage from Commandline`_ +- `Installation and Upgrade`_ - `Requirements`_ - `Acknowledgements`_ - `Contribute`_ @@ -90,95 +90,6 @@ tested on linux "bionic" with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 -Installation and Upgrade ------------------------- - -- Before You start, its highly recommended to update pip and setup tools: - - -.. code-block:: bash - - python -m pip --upgrade pip - python -m pip --upgrade setuptools - python -m pip --upgrade wheel - -- to install the latest release from PyPi via pip (recommended): - -.. code-block:: bash - - # install latest release from PyPi - python -m pip install --upgrade rst_include - - # test latest release from PyPi without installing (can be skipped) - python -m pip install rst_include --install-option test - -- to install the latest development version from github via pip: - - -.. code-block:: bash - - # normal install - python -m pip install --upgrade git+https://github.com/bitranox/rst_include.git - - # to test without installing (can be skipped) - python -m pip install git+https://github.com/bitranox/rst_include.git --install-option test - - # to install and upgrade all dependencies regardless of version number - python -m pip install --upgrade git+https://github.com/bitranox/rst_include.git --upgrade-strategy eager - - -- include it into Your requirements.txt: - -.. code-block:: bash - - # Insert following line in Your requirements.txt: - # for the latest Release on pypi: - rst_include - - # for the latest development version : - rst_include @ git+https://github.com/bitranox/rst_include.git - - # to install and upgrade all modules mentioned in requirements.txt: - python -m pip install --upgrade -r //requirements.txt - - - -- to install the latest development version from source code: - -.. code-block:: bash - - # cd ~ - $ git clone https://github.com/bitranox/rst_include.git - $ cd rst_include - - # to test without installing (can be skipped) - python setup.py test - - # normal install - python setup.py install - -- via makefile: - makefiles are a very convenient way to install. Here we can do much more, - like installing virtual environments, clean caches and so on. - -.. code-block:: shell - - # from Your shell's homedirectory: - $ git clone https://github.com/bitranox/rst_include.git - $ cd rst_include - - # to run the tests: - $ make test - - # to install the package - $ make install - - # to clean the package - $ make clean - - # uninstall the package - $ make uninstall - Usage ----------- @@ -455,6 +366,95 @@ Usage from Commandline info get program informations replace replace with times +Installation and Upgrade +------------------------ + +- Before You start, its highly recommended to update pip and setup tools: + + +.. code-block:: bash + + python -m pip --upgrade pip + python -m pip --upgrade setuptools + python -m pip --upgrade wheel + +- to install the latest release from PyPi via pip (recommended): + +.. code-block:: bash + + # install latest release from PyPi + python -m pip install --upgrade rst_include + + # test latest release from PyPi without installing (can be skipped) + python -m pip install rst_include --install-option test + +- to install the latest development version from github via pip: + + +.. code-block:: bash + + # normal install + python -m pip install --upgrade git+https://github.com/bitranox/rst_include.git + + # to test without installing (can be skipped) + python -m pip install git+https://github.com/bitranox/rst_include.git --install-option test + + # to install and upgrade all dependencies regardless of version number + python -m pip install --upgrade git+https://github.com/bitranox/rst_include.git --upgrade-strategy eager + + +- include it into Your requirements.txt: + +.. code-block:: bash + + # Insert following line in Your requirements.txt: + # for the latest Release on pypi: + rst_include + + # for the latest development version : + rst_include @ git+https://github.com/bitranox/rst_include.git + + # to install and upgrade all modules mentioned in requirements.txt: + python -m pip install --upgrade -r //requirements.txt + + + +- to install the latest development version from source code: + +.. code-block:: bash + + # cd ~ + $ git clone https://github.com/bitranox/rst_include.git + $ cd rst_include + + # to test without installing (can be skipped) + python setup.py test + + # normal install + python setup.py install + +- via makefile: + makefiles are a very convenient way to install. Here we can do much more, + like installing virtual environments, clean caches and so on. + +.. code-block:: shell + + # from Your shell's homedirectory: + $ git clone https://github.com/bitranox/rst_include.git + $ cd rst_include + + # to run the tests: + $ make test + + # to install the package + $ make install + + # to clean the package + $ make clean + + # uninstall the package + $ make uninstall + Requirements ------------ following modules will be automatically installed : @@ -463,6 +463,7 @@ following modules will be automatically installed : ## Project Requirements click + cli_exit_tools @ git+https://github.com/bitranox/cli_exit_tools.git lib_list @ git+https://github.com/bitranox/lib_list.git lib_log_utils @ git+https://github.com/bitranox/lib_log_utils.git pathlib3x @ git+https://github.com/bitranox/pathlib3x.git @@ -493,10 +494,11 @@ Changelog - new PATCH version for backwards compatible bug fixes -2.0.5a0 +2.0.5 ------- -2020-07-23: development - - +2020-07-29: feature release + - use the new pizzacutter template + - use cli_exit_tools 2.0.4 ----- diff --git a/pytest.ini b/pytest.ini index a7827d9..5df4c41 100644 --- a/pytest.ini +++ b/pytest.ini @@ -13,7 +13,6 @@ addopts = -vvl doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES IGNORE_EXCEPTION_DETAIL -doctest-glob = '*.rst' log_cli = True # this log level is used to intentionally log on pytest log_cli_level = CRITICAL diff --git a/requirements.txt b/requirements.txt index 951d03f..1658773 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ ## Project Requirements click +cli_exit_tools @ git+https://github.com/bitranox/cli_exit_tools.git lib_list @ git+https://github.com/bitranox/lib_list.git lib_log_utils @ git+https://github.com/bitranox/lib_log_utils.git pathlib3x @ git+https://github.com/bitranox/pathlib3x.git diff --git a/rst_include/__init__conf__.py b/rst_include/__init__conf__.py index d5ca9c3..396fea9 100644 --- a/rst_include/__init__conf__.py +++ b/rst_include/__init__conf__.py @@ -1,6 +1,6 @@ name = 'rst_include' title = 'commandline tool to resolve RST File includes' -version = '2.0.5a0' +version = '2.0.5' url = 'https://github.com/bitranox/rst_include' author = 'Robert Nowotny' author_email = 'bitranox@gmail.com' @@ -14,7 +14,7 @@ def print_info() -> None: commandline tool to resolve RST File includes - Version : 2.0.5a0 + Version : 2.0.5 Url : https://github.com/bitranox/rst_include Author : Robert Nowotny Email : bitranox@gmail.com""") diff --git a/rst_include/cli_exit_tools.py b/rst_include/cli_exit_tools.py deleted file mode 100644 index 05b90ac..0000000 --- a/rst_include/cli_exit_tools.py +++ /dev/null @@ -1,143 +0,0 @@ -import sys -import traceback -from typing import Any, TextIO - - -class _Config(object): - traceback: bool = False - - -config = _Config() - - -def get_system_exit_code(exc: BaseException) -> int: - """ - Return the exit code for linux or windows, based on the exception. - If, on windows, the winerror is set on the Exception, we return that winerror code. - - >>> try: - ... raise RuntimeError() - ... except RuntimeError as exc: - ... assert get_system_exit_code(exc) == 1 - ... setattr(exc, 'winerror', 42) - ... assert get_system_exit_code(exc) == 42 - ... setattr(exc, 'winerror', None) - ... assert get_system_exit_code(exc) == 1 - - """ - - # from https://www.thegeekstuff.com/2010/10/linux-error-codes - # dict key sorted from most specific to unspecific - posix_exceptions = {FileNotFoundError: 2, PermissionError: 13, FileExistsError: 17, TypeError: 22, - ValueError: 22, RuntimeError: 1, BaseException: 1} - windows_exceptions = {FileNotFoundError: 2, PermissionError: 5, ValueError: 13, FileExistsError: 80, TypeError: 87, - RuntimeError: 1, BaseException: 1} - - if hasattr(exc, 'winerror'): - try: - exit_code = int(exc.winerror) # type: ignore - return exit_code - except (AttributeError, TypeError): - pass - - if 'posix' in sys.builtin_module_names: - exceptions = posix_exceptions - else: - exceptions = windows_exceptions - - for exception in exceptions: - if isinstance(exc, exception): - return exceptions[exception] - # this should never happen - return 1 # pragma: no cover - - -def print_exception_message(trace_back: bool = config.traceback, stream: TextIO = sys.stderr) -> None: - """ - Prints the Exception Message to stderr - - if trace_back is True, it also prints the traceback information - - - >>> # test with exc_info = None - >>> print_exception_message() - - >>> # test with exc_info - >>> try: - ... raise FileNotFoundError('test') - ... except Exception: # noqa - ... print_exception_message(False) - ... print_exception_message(True) - - >>> # test with subprocess to get stdout, stderr - >>> import subprocess - >>> try: - ... discard=subprocess.run('unknown_command', shell=True, check=True) - ... except subprocess.CalledProcessError: - ... print_exception_message(False) - ... print_exception_message(True) - - """ - exc_info = sys.exc_info()[1] - if exc_info is not None: - exc_info_type = type(exc_info).__name__ - exc_info_msg = ''.join([exc_info_type, ': ', str(exc_info.args[0])]) - if trace_back: - print_stdout(exc_info) - print_stderr(exc_info) - exc_info_msg = ''.join(['Traceback Information : \n', str(traceback.format_exc())]).rstrip('\n') - print(exc_info_msg, file=stream) - - -def print_stdout(exc_info: Any) -> None: - """ - >>> class ExcInfo(object): - ... pass - - >>> exc_info = ExcInfo() - - >>> # test no stdout attribute - >>> print_stdout(exc_info) - - >>> # test stdout=None - >>> exc_info.stdout=None - >>> print_stdout(exc_info) - - >>> # test stdout - >>> exc_info.stdout=b'test' - >>> print_stdout(exc_info) - STDOUT: test - - """ - encoding = sys.getdefaultencoding() - if hasattr(exc_info, 'stdout'): - if exc_info.stdout is not None: - assert isinstance(exc_info.stdout, bytes) - print('STDOUT: ' + exc_info.stdout.decode(encoding)) - - -def print_stderr(exc_info: Any) -> None: - """ - >>> class ExcInfo(object): - ... pass - - >>> exc_info = ExcInfo() - - >>> # test no stdout attribute - >>> print_stderr(exc_info) - - >>> # test stdout=None - >>> exc_info.stderr=None - >>> print_stderr(exc_info) - - >>> # test stdout - >>> exc_info.stderr=b'test' - >>> print_stderr(exc_info) - STDERR: test - - """ - encoding = sys.getdefaultencoding() - if hasattr(exc_info, 'stderr'): - if exc_info.stderr is not None: - assert isinstance(exc_info.stderr, bytes) - print('STDERR: ' + exc_info.stderr.decode(encoding)) diff --git a/rst_include/rst_include_cli.py b/rst_include/rst_include_cli.py index afa7b7a..66093d8 100644 --- a/rst_include/rst_include_cli.py +++ b/rst_include/rst_include_cli.py @@ -5,19 +5,21 @@ # EXT import click -# CONSTANTS -CLICK_CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) +# OWN +import cli_exit_tools +# PROJ try: from . import __init__conf__ - from . import cli_exit_tools from . import rst_include except (ImportError, ModuleNotFoundError): # pragma: no cover # imports for doctest import __init__conf__ # type: ignore # pragma: no cover - import cli_exit_tools # type: ignore # pragma: no cover import rst_include # type: ignore # pragma: no cover +# CONSTANTS +CLICK_CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + def info() -> None: """ @@ -84,3 +86,5 @@ def cli_replace(source: str, target: str, str_pattern: str, str_replace: str, co except Exception as exc: cli_exit_tools.print_exception_message() sys.exit(cli_exit_tools.get_system_exit_code(exc)) + finally: + cli_exit_tools.flush_streams() diff --git a/setup.py b/setup.py index 2d72aa9..291ef90 100644 --- a/setup.py +++ b/setup.py @@ -83,7 +83,7 @@ def get_line_data(line: str) -> str: setup_kwargs: Dict[str, Any] = dict() setup_kwargs['name'] = 'rst_include' -setup_kwargs['version'] = '2.0.5a0' +setup_kwargs['version'] = '2.0.5' setup_kwargs['url'] = 'https://github.com/bitranox/rst_include' setup_kwargs['packages'] = find_packages() setup_kwargs['package_data'] = {'rst_include': ['py.typed', '*.pyi', '__init__.pyi']} diff --git a/travis_secrets/create_secrets.sh b/travis_secrets/create_secrets.sh index e1c5be8..40dc261 100644 --- a/travis_secrets/create_secrets.sh +++ b/travis_secrets/create_secrets.sh @@ -11,7 +11,7 @@ install_dependencies banner "this will encrypt the name and the value of a secret environment variable for travis. common secrets for the PizzaCutter Python Template are: -\"CC_TEST_REPORTER_ID\" and \"pypi_password\"" +\"CC_TEST_REPORTER_ID\" and \"PYPI_PASSWORD\"" read -r -p 'variable name :' var_name read -r -p 'variable value :' var_value diff --git a/travis_secrets/secrets/PYPI_PASSWORD.secret.txt b/travis_secrets/secrets/PYPI_PASSWORD.secret.txt new file mode 100644 index 0000000..681ae44 --- /dev/null +++ b/travis_secrets/secrets/PYPI_PASSWORD.secret.txt @@ -0,0 +1 @@ +"DrfW5T9mXVPBREpmvqHm/lGeNINRXo7aCFXiW5RVGoyFR2GsdZuF8GQQX9SFBGm46bgQ9cuCQErEkwxxa5nBIXbfEIpn4TMDZ/JSbS7zWk4WT6VSuRXl2ibiKfZP53mR/+AAdJvoSY72JlDr6q1p/M9AMj816n5mvanDmebUQNiUHIksuRZR3I2RBAHj3aWb1AOYSg6WIMZernacamSnY4KCodYL5FXxjASHuyxP2vtU+tgrLmUxRtFX5zvPFAMv/0372cS/QSizwnuYbX2MU8UFuxsrBZISGuUtehItJ7/aYjhFzYN8CKad90OFqQNwQ+Tbd828vxq3kbKByVrZqbh5eJGDGBfZobFxOyEXIqfNcwVrVE5XDVbY6+BTu+YMXCJe/scHL6nxkKM8vs32LgofHo4RChY9HG8IHPzN2hgwohivBCnmzh4MpArfOXpAVXhhpioFcvKpaigiX35c1+Z4S3tdz6ERyzCox+tVAlZs5gUgNsU+ZVUbquHSRSo3+e+fAfc7NqZs+VjzIApUbxGHYn2GMSACuIwQLKOrNsWlAvJZ0BalstVyDEXESRjDwx0Z45WP88MjXUFVJIfFHMJzu0OtGPFY3QGIZIgxiZMei3/D0c8dU0gyMLZuwJZGHCkchTKTo6ZgdsNGnf+e3x3J0VyXHTENT0GuyYhKN88=" diff --git a/travis_secrets/secrets/pypi_password.secret.txt b/travis_secrets/secrets/pypi_password.secret.txt deleted file mode 100644 index d117b38..0000000 --- a/travis_secrets/secrets/pypi_password.secret.txt +++ /dev/null @@ -1 +0,0 @@ -"jNc+2qZfnAIzMh4rUshJCDzjADSSZr+AsX3xA5W5tnLVBBHGu0aKsmify/biKWKe67n+hvJyXWWnchtEEulvZR66TQ0VLDSXTVO5JDx2nTakff5nPRkveayxDFE/H6Xz5wdg8o3G1NcKHQWSDojaQWPRTb3KivQ3Xr4aydEX/i3PqEgSGHg2tT/DbGmFbA9e0EILH28aPx4v9CnvkvpH1R7Qzy3BzaIFVVcj5kKHV9iPzDxvGDRfHha6EQSS2ScWUnyT4fWSHi7aIcpKL4lYSBxHVOHOSIuBbFRIvwP2J1zrS1tQL7VP21V5x7XsI8kIzTZ4DP7UR5+gXOELJ66CpHOR3Kvf6DLw6sc5AV1bpr63g/pqXPk9lQOWa2pK12sX4Zk8JwNr649t930wC0vCIPYQ1sXdx2K+4YRmflMi5RDC0NRM1e+obYOsaKtwzbNsBKJ0ngjcHXYsLt0Wessqeq+SwU4+l/pIFBQup3Waaa2lTT3Y7dShNyNfQebAq2VSCa0vY/UqiTNk+ucf2xlR6thIlj1aiOXSyxeiPsD3GP0wkb1BGpEGS54UULf91RA0zXz2pYxVnw1x4ptlW3nTPqHEmOB55sGtxb/ek4jRDtcqlIw2SojjWfWk56VazEEE6gsHN+xX2ooXi+zsWn4+5xXqyBkzzZseJJCb3qBXAVI=" From 8f5cc0f4869bae45c108c0a77680fceca409c045 Mon Sep 17 00:00:00 2001 From: bitranox Date: Wed, 29 Jul 2020 19:51:00 +0200 Subject: [PATCH 3/3] refractor --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 112a7c7..e13dadc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,10 @@ env: - cPIP="python -m pip" # switch off wine fix me messages - WINEDEBUG=fixme-all + # mypy path + - MYPYPATH="./rst_include/3rd_party_stubs" + # package name + - PACKAGE_NAME="rst_include" # the registered CLI Command - CLI_COMMAND=rst_include # the source file for rst_include (rebuild rst file includes) @@ -78,7 +82,7 @@ matrix: python: "3.8" before_install: - export MYPY_STRICT="True" - - export BUILD_DOCS="True" + - export BUILD_DOCS="False" - export DEPLOY_CHECK="True" - export DEPLOY="True"