From 5b40304025aa7d0880c27dee8163478ad180af97 Mon Sep 17 00:00:00 2001 From: Zethson Date: Mon, 7 Dec 2020 19:42:15 +0100 Subject: [PATCH 01/20] initial template commit Signed-off-by: Zethson --- .bandit.yml | 7 + .cookietemple.yml | 20 +++ .coveragerc | 4 + .editorconfig | 22 +++ .github/ISSUE_TEMPLATE/bug_report.md | 32 ++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++ .github/ISSUE_TEMPLATE/general_question.md | 13 ++ .github/dependabot.yml | 12 ++ .github/pull_request_template.md | 23 +++ .github/workflows/build_package.yml | 33 ++++ .../workflows/check_no_SNAPSHOT_master.yml | 43 +++++ .../check_patch_release_master_only.yml | 36 ++++ .github/workflows/publish_docs.yml | 38 +++++ .github/workflows/publish_package.yml | 33 ++++ .github/workflows/run_bandit.yml | 27 +++ .github/workflows/run_codecov.yml | 34 ++++ .github/workflows/run_cookietemple_lint.yml | 25 +++ .github/workflows/run_flake8_linting.yml | 30 ++++ .github/workflows/run_tox_testsuite.yml | 27 +++ .github/workflows/sync_project.yml | 34 ++++ .gitignore | 136 +++++++++++++++ .readthedocs.yml | 23 +++ AUTHORS.rst | 13 ++ CHANGELOG.rst | 19 +++ CODE_OF_CONDUCT.rst | 81 +++++++++ Dockerfile | 9 + LICENSE | 15 ++ MANIFEST.in | 12 ++ Makefile | 5 + README.rst | 45 +++++ cookietemple.cfg | 16 ++ cookietemple/__init__.py | 5 + cookietemple/cli.py | 37 ++++ cookietemple/cookietemple.py | 1 + cookietemple/files/test.txt | 2 + docs/Makefile | 20 +++ docs/_static/custom_cookietemple.css | 141 +++++++++++++++ docs/authors.rst | 1 + docs/changelog.rst | 1 + docs/code_of_conduct.rst | 1 + docs/conf.py | 161 ++++++++++++++++++ docs/index.rst | 19 +++ docs/installation.rst | 51 ++++++ docs/make.bat | 36 ++++ docs/modules.rst | 6 + docs/readme.rst | 1 + docs/requirements.txt | 4 + docs/usage.rst | 7 + makefiles/Linux.mk | 84 +++++++++ makefiles/Windows.mk | 85 +++++++++ requirements.txt | 2 + requirements_dev.txt | 13 ++ setup.cfg | 14 ++ setup.py | 77 +++++++++ tests/__init__.py | 1 + tests/test_cookietemple.py | 51 ++++++ tox.ini | 25 +++ 57 files changed, 1733 insertions(+) create mode 100644 .bandit.yml create mode 100644 .cookietemple.yml create mode 100644 .coveragerc create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/general_question.md create mode 100644 .github/dependabot.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/build_package.yml create mode 100644 .github/workflows/check_no_SNAPSHOT_master.yml create mode 100644 .github/workflows/check_patch_release_master_only.yml create mode 100644 .github/workflows/publish_docs.yml create mode 100644 .github/workflows/publish_package.yml create mode 100644 .github/workflows/run_bandit.yml create mode 100644 .github/workflows/run_codecov.yml create mode 100644 .github/workflows/run_cookietemple_lint.yml create mode 100644 .github/workflows/run_flake8_linting.yml create mode 100644 .github/workflows/run_tox_testsuite.yml create mode 100644 .github/workflows/sync_project.yml create mode 100644 .gitignore create mode 100644 .readthedocs.yml create mode 100644 AUTHORS.rst create mode 100644 CHANGELOG.rst create mode 100644 CODE_OF_CONDUCT.rst create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.rst create mode 100644 cookietemple.cfg create mode 100644 cookietemple/__init__.py create mode 100644 cookietemple/cli.py create mode 100644 cookietemple/cookietemple.py create mode 100644 cookietemple/files/test.txt create mode 100644 docs/Makefile create mode 100644 docs/_static/custom_cookietemple.css create mode 100644 docs/authors.rst create mode 100644 docs/changelog.rst create mode 100644 docs/code_of_conduct.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/installation.rst create mode 100644 docs/make.bat create mode 100644 docs/modules.rst create mode 100644 docs/readme.rst create mode 100644 docs/requirements.txt create mode 100644 docs/usage.rst create mode 100644 makefiles/Linux.mk create mode 100644 makefiles/Windows.mk create mode 100644 requirements.txt create mode 100644 requirements_dev.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/test_cookietemple.py create mode 100644 tox.ini diff --git a/.bandit.yml b/.bandit.yml new file mode 100644 index 00000000..cbb31a3c --- /dev/null +++ b/.bandit.yml @@ -0,0 +1,7 @@ +### profile may optionally select or skip tests + +# (optional) list included tests here: +tests: [] + +# (optional) list skipped tests here: +skips: ['B403', 'B404', 'B603', 'B607'] diff --git a/.cookietemple.yml b/.cookietemple.yml new file mode 100644 index 00000000..1909fdb2 --- /dev/null +++ b/.cookietemple.yml @@ -0,0 +1,20 @@ +cookietemple_version: '1.2.2-SNAPSHOT # <>' +domain: cli +language: python +project_slug: cookietemple +project_slug_no_hyphen: cookietemple +template_version: '1.0.1 # <>' +template_handle: cli-python +github_username: zethson +creator_github_username: zethson +is_github_repo: false +is_repo_private: false +is_github_orga: false +full_name: Lukas Heumos +email: lukas.heumos@posteo.net +project_name: cookietemple +project_short_description: cookietemple. A cookietemple based . +version: 1.2.2 +license: Apache2.0 +command_line_interface: Click +testing_library: pytest diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..604d7dab --- /dev/null +++ b/.coveragerc @@ -0,0 +1,4 @@ +[run] +omit = + # omit the setup.py + setup.py diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..0bfc6a66 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 +end_of_line = lf + +[*.bat] +indent_style = tab +end_of_line = crlf + +[LICENSE] +insert_final_newline = false + +[Makefile] +indent_style = tab + diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..dcc2bcbc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,32 @@ +--- +name: Bug report +about: Create a bug report to help us improve +title: 'Bug Summary' +labels: 'bug' +assignees: '' + +--- + +**Describe the bug** + + + +**To Reproduce** + +Steps to reproduce the behavior: +1. ... +2. ... +3. ... + +**Expected behavior** + + +**System [please complete the following information]:** + + - OS: e.g. [Ubuntu 18.04] + - Language Version: [e.g. Python 3.8] + - Virtual environment: [e.g. Conda] + +**Additional context** + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..213545de --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest a new feature +title: 'Feature Request Summary' +labels: 'enhancement' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** + + + +**Describe the solution you would like** + + + +**Additional context** + + diff --git a/.github/ISSUE_TEMPLATE/general_question.md b/.github/ISSUE_TEMPLATE/general_question.md new file mode 100644 index 00000000..8c3f2b20 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/general_question.md @@ -0,0 +1,13 @@ +--- +name: General question +about: Ask a question about anything related to this project +title: 'Question' +labels: 'question' +assignees: '' + +--- + +**Question** + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..7b1bdfb2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + target-branch: development + labels: + - DEPENDABOT + commit-message: + prefix: "[DEPENDABOT]" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..de8f0bb2 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,23 @@ + + +**PR Checklist** + + + + - [ ] This comment contains a description of changes (with reason) + - [ ] Referenced issue is linked + - [ ] If you've fixed a bug or added code that should be tested, add tests! + - [ ] Documentation in `docs` is updated + - [ ] `CHANGELOG.rst` is updated + +**Description of changes** + + + +**Technical details** + + + +**Additional context** + + diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml new file mode 100644 index 00000000..dbe79a12 --- /dev/null +++ b/.github/workflows/build_package.yml @@ -0,0 +1,33 @@ +name: Build cookietemple Package + +on: [push] + +jobs: + build: + runs-on: ${{ matrix.os }} + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + python: [3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + name: Check out source-code repository + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }} + + - name: Build cookietemple + run: pip install . + + - name: Install required twine packaging dependencies + run: pip install setuptools wheel twine + + - name: Build twine package + run: python setup.py sdist bdist_wheel + + - name: Check twine package + run: twine check dist/* diff --git a/.github/workflows/check_no_SNAPSHOT_master.yml b/.github/workflows/check_no_SNAPSHOT_master.yml new file mode 100644 index 00000000..8d408417 --- /dev/null +++ b/.github/workflows/check_no_SNAPSHOT_master.yml @@ -0,0 +1,43 @@ +name: No SNAPSHOT version on master branch + +on: + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + # PRs to the repository master branch are only ok if coming from any patch or release branch + - name: Install cookietemple + run: pip install cookietemple + + - name: Check project version + run: | + PROJECTVERSION=$(cookietemple bump-version --project-version . | tail -n1) + echo $PROJECTVERSION; + if [[ $PROJECTVERSION == *"SNAPSHOT"* ]];then + exit -1 + else + exit 0 + fi + + # If the above check failed, post a comment on the PR explaining the failure + # NOTE - this may not work if the PR is coming from a fork, due to limitations in GitHub actions secrets + - name: Post PR comment + if: failure() + uses: mshick/add-pr-comment@v1 + with: + message: | + Hi @${{ github.event.pull_request.user.login }}, + + It looks like this pull-request is has been made against the ${{github.event.pull_request.head.repo.full_name}} `master` branch. + A version check determined that you are using a SNAPSHOT version. + The `master` branch should never have any SNAPSHOT versions, since only fully stable code should be on the `master` branch. + repo-token: ${{ secrets.GITHUB_TOKEN }} + allow-repeats: false diff --git a/.github/workflows/check_patch_release_master_only.yml b/.github/workflows/check_patch_release_master_only.yml new file mode 100644 index 00000000..1a8f1f4a --- /dev/null +++ b/.github/workflows/check_patch_release_master_only.yml @@ -0,0 +1,36 @@ +name: PR to master branch from PATCH/release branch only + +on: + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + steps: + # PRs to the repository master branch are only ok if coming from any patch or release branch + - name: Check PRs + run: | + { [[ $GITHUB_HEAD_REF = *"release"* ]]; } || [[ $GITHUB_HEAD_REF == *"patch"* ]] + + + # If the above check failed, post a comment on the PR explaining the failure + # NOTE - this may not work if the PR is coming from a fork, due to limitations in GitHub actions secrets + - name: Post PR comment + if: failure() + uses: mshick/add-pr-comment@v1 + with: + message: | + Hi @${{ github.event.pull_request.user.login }}, + + It looks like this pull-request is has been made against the ${{github.event.pull_request.head.repo.full_name}} `master` branch. + The `master` branch should always contain code from the latest release. + Because of this, PRs to `master` are only allowed if they come from any ${{github.event.pull_request.head.repo.full_name}} `release` or `patch` branch. + + You do not need to close this PR, you can change the target branch to `development` by clicking the _"Edit"_ button at the top of this page. + + Thanks again for your contribution! + repo-token: ${{ secrets.GITHUB_TOKEN }} + allow-repeats: false + diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/publish_docs.yml new file mode 100644 index 00000000..a1541fe7 --- /dev/null +++ b/.github/workflows/publish_docs.yml @@ -0,0 +1,38 @@ +name: Build Documentation + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + name: Check out source-code repository + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install pip + run: | + python -m pip install --upgrade pip + + - name: Install doc dependencies + run: | + pip install -r docs/requirements.txt + + - name: Build docs + run: | + cd docs + make html + + - name: Deploy + if: ${{ github.ref == 'refs/heads/master' }} + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/_build/html + diff --git a/.github/workflows/publish_package.yml b/.github/workflows/publish_package.yml new file mode 100644 index 00000000..9bfe3fee --- /dev/null +++ b/.github/workflows/publish_package.yml @@ -0,0 +1,33 @@ +name: Publish cookietemple to PyPI + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + steps: + - uses: actions/checkout@v2 + name: Check out source-code repository + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.8' + + - name: Install pip, setuptools, wheel, twine + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + # TODO COOKIETEMPLE: Configure your secrets to enable automatic deployment to PyPi on releases + # https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/run_bandit.yml b/.github/workflows/run_bandit.yml new file mode 100644 index 00000000..4ba4d813 --- /dev/null +++ b/.github/workflows/run_bandit.yml @@ -0,0 +1,27 @@ +name: Run bandit + +on: + push: + paths: + - "**/*.py" + +jobs: + build: + + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + + steps: + - uses: actions/checkout@v2 + name: Check out source-code repository + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install bandit + run: pip install bandit + + - name: Run bandit + run: bandit -r cookietemple -c .bandit.yml diff --git a/.github/workflows/run_codecov.yml b/.github/workflows/run_codecov.yml new file mode 100644 index 00000000..3b2f5365 --- /dev/null +++ b/.github/workflows/run_codecov.yml @@ -0,0 +1,34 @@ +name: Run Codecov +on: [push] + +jobs: + run: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + strategy: + matrix: + python: [3.7, 3.8] + steps: + - uses: actions/checkout@master + - name: Setup Python + uses: actions/setup-python@master + with: + python-version: ${{ matrix.python }} + + - name: Generate coverage report + run: | + pip install -r requirements_dev.txt + pip install pytest-cov + pytest --cov-config=.coveragerc --cov=cookietemple/ --cov-report=xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + #TODO COOKIETEMPLE: If your repository is private you are required to set a CODECOV_TOKEN as a secret into your Github repository. + #See: https://docs.codecov.io/docs/about-the-codecov-bash-uploader#upload-token and + #https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets. + #No token is required if your repository is public. + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false diff --git a/.github/workflows/run_cookietemple_lint.yml b/.github/workflows/run_cookietemple_lint.yml new file mode 100644 index 00000000..03b5fac2 --- /dev/null +++ b/.github/workflows/run_cookietemple_lint.yml @@ -0,0 +1,25 @@ +name: cookietemple lint + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + name: Check out source-code repository + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Install cookietemple + run: | + pip install cookietemple + + - name: Run cookietemple lint + run: | + cookietemple lint . --skip-external diff --git a/.github/workflows/run_flake8_linting.yml b/.github/workflows/run_flake8_linting.yml new file mode 100644 index 00000000..34df5f85 --- /dev/null +++ b/.github/workflows/run_flake8_linting.yml @@ -0,0 +1,30 @@ +name: Run flake8 linting + +on: + push: + paths: + - "**/*.py" + +jobs: + build: + + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + + steps: + - uses: actions/checkout@v2 + name: Check out source-code repository + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install pip + run: | + python -m pip install --upgrade pip + + - name: Lint with flake8 + run: | + pip install flake8 + flake8 . diff --git a/.github/workflows/run_tox_testsuite.yml b/.github/workflows/run_tox_testsuite.yml new file mode 100644 index 00000000..8ef92bfc --- /dev/null +++ b/.github/workflows/run_tox_testsuite.yml @@ -0,0 +1,27 @@ +name: Run cookietemple Tox Test Suite + +on: [push] + +jobs: + test: + runs-on: ${{ matrix.os }} + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + python: [3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + name: Check out source-code repository + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }} + + - name: Install Tox + run: pip install tox + + - name: Run Tox + run: tox -e py # Run tox using the version of Python in `PATH` diff --git a/.github/workflows/sync_project.yml b/.github/workflows/sync_project.yml new file mode 100644 index 00000000..d290c9cd --- /dev/null +++ b/.github/workflows/sync_project.yml @@ -0,0 +1,34 @@ +name: cookietemple sync + +on: + schedule: + - cron: '0 1 * * *' # 1 am UTC + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install cookietemple + run: pip install cookietemple + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: '${{ secrets.CT_SYNC_TOKEN }}' + name: Check out source-code repository + + - uses: oleksiyrudenko/gha-git-credentials@v2 + with: + name: 'zethson' + email: 'lukas.heumos@posteo.net' + actor: 'zethson' + token: '${{ secrets.CT_SYNC_TOKEN}}' + + - name: Sync project + run: cookietemple sync . ${{ secrets.CT_SYNC_TOKEN }} zethson diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3e5b31ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,136 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Jetbrains IDE +.idea/ + +# Coala +*.orig + diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 00000000..f9a828d1 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,23 @@ +# .readthedocs.yml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/conf.py + +# Build documentation with MkDocs +#mkdocs: +# configuration: mkdocs.yml + +# Optionally build your docs in additional formats such as PDF and ePub +formats: all + +# Optionally set the version of Python and requirements required to build your docs +python: + version: 3.8 + install: + - requirements: docs/requirements.txt diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 00000000..498fbb07 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,13 @@ +======= +Credits +======= + +Development Lead +---------------- + +* Lukas Heumos + +Contributors +------------ + +None yet. Why not be the first? diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 00000000..e7301c8e --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,19 @@ +========== +Changelog +========== + +This project adheres to `Semantic Versioning `_. + + +1.2.2 (2020-12-07) +----------------------- + +**Added** + +* Created the project using cookietemple version 1.2.2-SNAPSHOT + +**Fixed** + +**Dependencies** + +**Deprecated** diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst new file mode 100644 index 00000000..8a27c88e --- /dev/null +++ b/CODE_OF_CONDUCT.rst @@ -0,0 +1,81 @@ +Contributor Covenant Code of Conduct +==================================== + +Our Pledge +---------- + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our +project and our community a harassment-free experience for everyone, +regardless of age, body size, disability, ethnicity, gender identity and +expression, level of experience, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +Our Standards +------------- + +Examples of behavior that contributes to creating a positive environment +include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual + attention or advances +- Trolling, insulting/derogatory comments, and personal or political + attacks +- Public or private harassment +- Publishing others’ private information, such as a physical or + electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +Our Responsibilities +-------------------- + +Project maintainers are responsible for clarifying the standards of +acceptable behavior and are expected to take appropriate and fair +corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, +or reject comments, commits, code, wiki edits, issues, and other +contributions that are not aligned to this Code of Conduct, or to ban +temporarily or permanently any contributor for other behaviors that they +deem inappropriate, threatening, offensive, or harmful. + +Scope +----- + +This Code of Conduct applies both within project spaces and in public +spaces when an individual is representing the project or its community. +Examples of representing a project or community include using an +official project e-mail address, posting via an official social media +account, or acting as an appointed representative at an online or +offline event. Representation of a project may be further defined and +clarified by project maintainers. + +Enforcement +----------- + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported by opening an issue. The project team +will review and investigate all complaints, and will respond in a way +that it deems appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an +incident. Further details of specific enforcement policies may be posted +separately. + +Project maintainers who do not follow or enforce the Code of Conduct in +good faith may face temporary or permanent repercussions as determined +by other members of the project’s leadership. + +Attribution +------------------- + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a3c41492 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.8.1-alpine + +# A few Utilities to able to install C based libraries such as numpy +RUN apk update +RUN apk add make automake gcc g++ git + +RUN pip install cookietemple + +CMD cookietemple diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b3420ca2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +Apache Software License 2.0 + +Copyright (c) 2020, Lukas Heumos + +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 at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed 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 and +limitations under the License. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..2e14c279 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,12 @@ +include AUTHORS.rst +include CONTRIBUTING.rst +include CHANGELOG.rst +include LICENSE +include README.rst +include requirements.txt + +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] + +recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..08a9f014 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +ifeq ($(OS),Windows_NT) +include makefiles/Windows.mk +else +include makefiles/Linux.mk +endif diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..4c027fb8 --- /dev/null +++ b/README.rst @@ -0,0 +1,45 @@ +============ +cookietemple +============ + +.. image:: https://github.com/zethson/cookietemple/workflows/Build%20cookietemple%20Package/badge.svg + :target: https://github.com/zethson/cookietemple/workflows/Build%20cookietemple%20Package/badge.svg + :alt: Github Workflow Build cookietemple Status + +.. image:: https://github.com/zethson/cookietemple/workflows/Run%20cookietemple%20Tox%20Test%20Suite/badge.svg + :target: https://github.com/zethson/cookietemple/workflows/Run%20cookietemple%20Tox%20Test%20Suite/badge.svg + :alt: Github Workflow Tests Status + +.. image:: https://img.shields.io/pypi/v/cookietemple.svg + :target: https://pypi.python.org/pypi/cookietemple + :alt: PyPI Status + + +.. image:: https://readthedocs.org/projects/cookietemple/badge/?version=latest + :target: https://cookietemple.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. image:: https://flat.badgen.net/dependabot/thepracticaldev/dev.to?icon=dependabot + :target: https://flat.badgen.net/dependabot/thepracticaldev/dev.to?icon=dependabot + :alt: Dependabot Enabled + + +cookietemple. A cookietemple based . + + +* Free software: Apache2.0 +* Documentation: https://cookietemple.readthedocs.io. + + +Features +-------- + +* TODO + +Credits +------- + +This package was created with cookietemple_ using Cookiecutter_. + +.. _cookietemple: https://cookietemple.com +.. _Cookiecutter: https://github.com/audreyr/cookiecutter diff --git a/cookietemple.cfg b/cookietemple.cfg new file mode 100644 index 00000000..dd9d5714 --- /dev/null +++ b/cookietemple.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 1.2.2 + +[bumpversion_files_whitelisted] +setup_file = setup.py +init_file = cookietemple/__init__.py +dot_cookietemple = .cookietemple.yml +conf_py = docs/conf.py + +[bumpversion_files_blacklisted] + +[sync_level] +ct_sync_level = minor + +[sync_files_blacklisted] +changelog = CHANGELOG.rst diff --git a/cookietemple/__init__.py b/cookietemple/__init__.py new file mode 100644 index 00000000..d95f6f26 --- /dev/null +++ b/cookietemple/__init__.py @@ -0,0 +1,5 @@ +"""Top-level package for cookietemple.""" + +__author__ = """Lukas Heumos""" +__email__ = 'lukas.heumos@posteo.net' +__version__ = '1.2.2' diff --git a/cookietemple/cli.py b/cookietemple/cli.py new file mode 100644 index 00000000..b383b8f3 --- /dev/null +++ b/cookietemple/cli.py @@ -0,0 +1,37 @@ +"""Console script for cookietemple.""" +import os +import sys +import click + +from rich import traceback + +WD = os.path.dirname(__file__) + + +@click.command() +def main(args=None): + """Console script for cookietemple.""" + read_included_file('test.txt') + + click.echo("Replace this message by putting your code into " + "cookietemple.cli.main") + click.echo("See click documentation at https://click.palletsprojects.com/") + return 0 + + +def read_included_file(filename): + """ + DELETE ME + + This method solely demonstrates how to use and read files, which are automatically included in the distributed python package. + @param filename: Name of the file to read, which has to be in a folder, that is included in the python package as specified in setup.py + """ + print("function is called") + with open(f"{WD}/files/{filename}") as f: + content = f.readlines() + print(content) + + +if __name__ == "__main__": + traceback.install() + sys.exit(main()) # pragma: no cover diff --git a/cookietemple/cookietemple.py b/cookietemple/cookietemple.py new file mode 100644 index 00000000..dd0b80ed --- /dev/null +++ b/cookietemple/cookietemple.py @@ -0,0 +1 @@ +"""Main module.""" diff --git a/cookietemple/files/test.txt b/cookietemple/files/test.txt new file mode 100644 index 00000000..92953e83 --- /dev/null +++ b/cookietemple/files/test.txt @@ -0,0 +1,2 @@ +I am a file called 'test.txt' which is automatically included and packaged. +I reside in the folder 'files' and that folder is specified in setup.py diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..538806a8 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = python -msphinx +SPHINXPROJ = cookietemple +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/_static/custom_cookietemple.css b/docs/_static/custom_cookietemple.css new file mode 100644 index 00000000..ff1006b2 --- /dev/null +++ b/docs/_static/custom_cookietemple.css @@ -0,0 +1,141 @@ +@import "basic.css"; + +/*Color main components with a dark theme*/ +div, span, code { + background-color: #181a1b !important; +} + +.wy-side-nav-search { + background-color: #005fff !important; +} + +.wy-side-nav-search div { + background-color: #005fff !important; +} + +/*Font color is mainly white*/ +.rst-content p, li, h1, h2, h3, h4, h5, h6, .highlight-console, .n, .section { + color: #FFFFFF; +} + +/*The side menu is slightly more grey and lighter than the overall theme*/ +.wy-menu, .wy-menu-vertical { + background-color: #2D2E2F !important; +} + +.wy-side-scroll { + background-color: #2D2E2F !important; +} + +.wy-menu .caption-text { + background-color: #2D2E2F !important; +} + +.caption-text { + background-color: #181a1b !important; +} + +.figure p { + background-color: #181a1b !important; +} + +/*Toctree wrapper on index page has a dark background unlike the other menu items*/ +.toctree-wrapper .compound ul .toctree-l1, .toctree-wrapper .compound ul .toctree-l2 { + background-color: #181a1b !important; + color: #005fff !important; +} + +/*The current menu section has a blue background*/ +.wy-menu-vertical li.toctree-l1.current li.toctree-l2 > a:hover { + color: #FFFFFF !important; + background: #005fff !important; +} + +/*Subitems under the current section are displayed in grey again*/ +.wy-menu-vertical li.toctree-l1.current li.toctree-l2 > a { + color: #FFFFFF !important; + background: #2D2E2F !important; +} + +/*Current hovered item has a blue background*/ +.wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a:hover { + color: #FFFFFF !important; + background: #005fff !important; +} + +.wy-menu-vertical li.toctree-l2.current > a:hover { + color: #FFFFFF !important; + background: #005fff !important; +} + +.wy-menu-vertical li.toctree-l2.current li.toctree-l3 > a { + color: #FFFFFF !important; + background: #2D2E2F !important; +} + +.wy-menu-vertical li.toctree-l1.current { + color: #FFFFFF !important; + background: #005fff !important; + border-color: #005fff !important; +} + +.wy-menu-vertical li.toctree-l1.current > a { + color: #FFFFFF !important; + background: #005fff !important; + border-color: #005fff !important; +} + +.wy-menu-vertical li.toctree-l1.current > a:hover { + color: #FFFFFF !important; + background: #005fff !important; + border-color: #005fff !important; +} + +/*The expand toctree items have the same background as its corresponding section*/ +.wy-menu-vertical li.toctree-l1 a span.toctree-expand { + background-color: #005fff !important; +} + +.wy-menu-vertical li.toctree-l2 a span.toctree-expand { + background-color: #2D2E2F !important; +} + +.wy-menu-vertical li.toctree-l2 a:hover span.toctree-expand { + background-color: #005fff !important; +} + +.wy-menu-vertical li.toctree-l3 a span.toctree-expand { + background-color: #2D2E2F !important; +} + +.wy-menu-vertical li.toctree-l3 a:hover span.toctree-expand { + background-color: #005fff !important; +} + +.code .docutils .literal .notranslate .pre { + background-color: #181a1b !important; +} + +/*Color footer separately corresponding to overall dark theme*/ +footer { + color: #FFFFFF; +} + +/*Color footer buttons in blue*/ +.rst-footer-buttons a, .rst-footer-buttons a:hover, .rst-footer-buttons span { + background-color: #005fff !important; +} + +.wy-side-nav-search a { + background-color: #005fff !important; +} + +.version { + background-color: #005fff !important; + color: #FFFFFF !important; +} + +/*Set max width to none so the theme uses all available width*/ +.wy-nav-content { + max-width: none; +} diff --git a/docs/authors.rst b/docs/authors.rst new file mode 100644 index 00000000..e122f914 --- /dev/null +++ b/docs/authors.rst @@ -0,0 +1 @@ +.. include:: ../AUTHORS.rst diff --git a/docs/changelog.rst b/docs/changelog.rst new file mode 100644 index 00000000..565b0521 --- /dev/null +++ b/docs/changelog.rst @@ -0,0 +1 @@ +.. include:: ../CHANGELOG.rst diff --git a/docs/code_of_conduct.rst b/docs/code_of_conduct.rst new file mode 100644 index 00000000..96e0ba2f --- /dev/null +++ b/docs/code_of_conduct.rst @@ -0,0 +1 @@ +.. include:: ../CODE_OF_CONDUCT.rst diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..10537bee --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python +# +# cookietemple documentation build configuration file +# +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another +# directory, add these directories to sys.path here. If the directory is +# relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('..')) + + +# -- General configuration --------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. + +# Add 'sphinx_automodapi.automodapi' if you want to build modules +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx_automodapi.automodapi'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'cookietemple' +copyright = "2020, Lukas Heumos" +author = "Lukas Heumos" + +# The version info for the project you're documenting, acts as replacement +# for |version| and |release|, also used in various other places throughout +# the built documents. +# +# The short X.Y version. +version = '1.2.2' +# The full version, including alpha/beta/rc tags. +release = '1.2.2' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' + +# Theme options are theme-specific and customize the look and feel of a +# theme further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + + +# -- Options for HTMLHelp output --------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'cookietempledoc' + + +# -- Options for LaTeX output ------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'cookietemple.tex', + 'cookietemple Documentation', + 'Lukas Heumos', 'manual'), +] + + +# -- Options for manual page output ------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'cookietemple', + 'cookietemple Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'cookietemple', + 'cookietemple Documentation', + author, + 'cookietemple', + 'One line description of project.', + 'Miscellaneous'), +] + +html_css_files = [ + 'custom_cookietemple.css', +] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..9f7e7de0 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,19 @@ +Welcome to cookietemple's documentation! +========================================= +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + readme + installation + usage + modules + authors + changelog + code_of_conduct + +Indices and tables +================== +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 00000000..2444d44b --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,51 @@ +.. highlight:: shell + +============ +Installation +============ + + +Stable release +-------------- + +To install cookietemple, run this command in your terminal: + +.. code-block:: console + + $ pip install cookietemple + +This is the preferred method to install cookietemple, as it will always install the most recent stable release. + +If you don't have `pip`_ installed, this `Python installation guide`_ can guide +you through the process. + +.. _pip: https://pip.pypa.io +.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ + + +From sources +------------ + +The sources for cookietemple can be downloaded from the `Github repo`_. + +You can either clone the public repository: + +.. code-block:: console + + $ git clone git://github.com/zethson/cookietemple + +Or download the `tarball`_: + +.. code-block:: console + + $ curl -OJL https://github.com/zethson/cookietemple/tarball/master + +Once you have a copy of the source, you can install it with: + +.. code-block:: console + + $ make install + + +.. _Github repo: https://github.com/zethson/cookietemple +.. _tarball: https://github.com/zethson/cookietemple/tarball/master diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..e0b7c985 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,36 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=python -msphinx +) +set SOURCEDIR=. +set BUILDDIR=_build +set SPHINXPROJ=cookietemple + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The Sphinx module was not found. Make sure you have Sphinx installed, + echo.then set the SPHINXBUILD environment variable to point to the full + echo.path of the 'sphinx-build' executable. Alternatively you may add the + echo.Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/modules.rst b/docs/modules.rst new file mode 100644 index 00000000..28d3e8c1 --- /dev/null +++ b/docs/modules.rst @@ -0,0 +1,6 @@ +======= +Modules +======= + +.. automodapi:: cookietemple.cookietemple + diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 00000000..72a33558 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..0a6d838e --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,4 @@ +Sphinx==2.4.4 +sphinx_rtd_theme==0.5.0 +sphinx-automodapi==0.12 +-r ../requirements.txt diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 00000000..67676c1b --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,7 @@ +===== +Usage +===== + +To use cookietemple in a project:: + + import cookietemple diff --git a/makefiles/Linux.mk b/makefiles/Linux.mk new file mode 100644 index 00000000..accea433 --- /dev/null +++ b/makefiles/Linux.mk @@ -0,0 +1,84 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -fr .tox/ + rm -f .coverage + rm -fr htmlcov/ + rm -fr .pytest_cache + +lint: ## check style with flake8 + flake8 cookietemple tests + +test: ## run tests quickly with the default Python + pytest + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source cookietemple -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov/index.html + +docs: ## generate Sphinx HTML documentation, including API docs + rm -f docs/cookietemple.rst + rm -f docs/modules.rst + sphinx-apidoc -o docs/ cookietemple + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs/_build/html/index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: dist ## package and upload a release + twine upload dist/* + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + +install: clean ## install the package to the active Python's site-packages + pip install . diff --git a/makefiles/Windows.mk b/makefiles/Windows.mk new file mode 100644 index 00000000..50e95ab6 --- /dev/null +++ b/makefiles/Windows.mk @@ -0,0 +1,85 @@ +.PHONY: clean clean-test clean-pyc clean-build docs help +.DEFAULT_GOAL := help + +define BROWSER_PYSCRIPT +import os, webbrowser, sys + +from urllib.request import pathname2url + +webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +endef +export BROWSER_PYSCRIPT + +define PRINT_HELP_PYSCRIPT +import re, sys + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print("%-20s %s" % (target, help)) +endef +export PRINT_HELP_PYSCRIPT + +BROWSER := python -c "$$BROWSER_PYSCRIPT" + +help: + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + if exist build rd /s /q build + if exist build rd /s /q dist + if exist build rd /s /q .eggs + for /d /r . %%d in (*.egg-info) do @if exist "%%d" echo "%%d" && rd /s/q "%%d" + del /q /s /f .\*.egg + + +clean-pyc: ## remove Python file artifacts + del /s /f /q .\*.pyc + del /s /f /q .\*.pyo + del /s /f /q .\*~ + for /d /r . %%d in (*__pycache__) do @if exist "%%d" echo "%%d" && rd /s/q "%%d" + +clean-test: ## remove test and coverage artifacts + if exist .tox rd /s /q .tox + if exist .coverage rd /s /q .coverage + if exist htmlcov rd /s /q htmlcov + if exist .pytest_cache rd /s /q .pytest_cache + +lint: ## check style with flake8 + flake8 cookietemple tests + +test: ## run tests quickly with the default Python + pytest + +test-all: ## run tests on every Python version with tox + tox + +coverage: ## check code coverage quickly with the default Python + coverage run --source cookietemple -m pytest + coverage report -m + coverage html + $(BROWSER) htmlcov\index.html + +docs: ## generate Sphinx HTML documentation, including API docs + del /f /q docs\cookietemple.rst + del /f /q docs\modules.rst + sphinx-apidoc -o docs cookietemple + $(MAKE) -C docs clean + $(MAKE) -C docs html + $(BROWSER) docs\_build\html\index.html + +servedocs: docs ## compile the docs watching for changes + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . + +release: dist ## package and upload a release + twine upload dist\* + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + +install: clean ## install the package to the active Python's site-packages + pip install . diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..8efaf0fa --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +rich==9.1.0 +click==7.1.2 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 00000000..b3bc190e --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,13 @@ +pip==20.2.4 +wheel==0.35.1 +watchdog==0.10.3 +flake8==3.8.4 +tox==3.20.1 +coverage==5.3 +Sphinx==3.3.0 +sphinx-automodapi==0.13 +twine==3.2.0 +pytest==6.1.2 +pytest-runner==5.2 +pytest-mock==3.3.1 +-r requirements.txt diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..dffdd234 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,14 @@ +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs +max-line-length = 160 + +[aliases] +# Define setup.py command aliases here +test = pytest + +[tool:pytest] +collect_ignore = ['setup.py'] + diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..e5eeb89c --- /dev/null +++ b/setup.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +"""The setup script.""" + +import os +import cookietemple as module +from setuptools import setup, find_packages + + +def walker(base, *paths): + file_list = set([]) + cur_dir = os.path.abspath(os.curdir) + + os.chdir(base) + try: + for path in paths: + for dname, dirs, files in os.walk(path): + for f in files: + file_list.add(os.path.join(dname, f)) + finally: + os.chdir(cur_dir) + + return list(file_list) + + +with open('README.rst') as readme_file: + readme = readme_file.read() + +with open('CHANGELOG.rst') as history_file: + history = history_file.read() + +with open('requirements.txt') as f: + requirements = f.read().splitlines() + +setup_requirements = ['pytest-runner', ] + +test_requirements = ['pytest>=3', ] + +setup( + author="Lukas Heumos", + author_email='lukas.heumos@posteo.net', + python_requires='>=3.7', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + ], + description="cookietemple. A cookietemple based .", + entry_points={ + 'console_scripts': [ + 'cookietemple=cookietemple.cli:main', + ], + }, + install_requires=requirements, + license="Apache2.0", + long_description=readme + '\n\n' + history, + include_package_data=True, + keywords='cookietemple', + name='cookietemple', + packages=find_packages(include=['cookietemple', 'cookietemple.*']), + package_data={ + module.__name__: walker( + os.path.dirname(module.__file__), + 'files' + ), + }, + setup_requires=setup_requirements, + test_suite='tests', + tests_require=test_requirements, + url='https://github.com/zethson/cookietemple', + version='1.2.2', + zip_safe=False, +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..5f3a82dd --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Unit test package for cookietemple.""" diff --git a/tests/test_cookietemple.py b/tests/test_cookietemple.py new file mode 100644 index 00000000..e71bcd5c --- /dev/null +++ b/tests/test_cookietemple.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +"""Tests for `cookietemple` package.""" +import os + +import pytest + +from click.testing import CliRunner + +# from cookietemple import cookietemple +from cookietemple import cli + + +@pytest.fixture +def response(): + """Sample pytest fixture. + + See more at: http://doc.pytest.org/en/latest/fixture.html + """ + import requests + return requests.get('https://github.com/torvalds/linux') + + +def test_content(response): + """Sample pytest test function with the pytest fixture as an argument.""" + # from bs4 import BeautifulSoup + # assert 'GitHub' in BeautifulSoup(response.content).title.string + + +class UnixFS: + + @staticmethod + def rm(filename): + os.remove(filename) + + +def test_unix_fs(mocker): + mocker.patch('os.remove') + UnixFS.rm('file') + os.remove.assert_called_once_with('file') + + +def test_command_line_interface(): + """Test the CLI.""" + runner = CliRunner() + result = runner.invoke(cli.main) + assert result.exit_code == 0 + assert 'cookietemple.cli.main' in result.output + help_result = runner.invoke(cli.main, ['--help']) + assert help_result.exit_code == 0 + assert '--help Show this message and exit.' in help_result.output diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..a8222714 --- /dev/null +++ b/tox.ini @@ -0,0 +1,25 @@ +[tox] +envlist = py37, py38, flake8 + +[travis] +python = + 3.8: py38 + 3.7: py37 + +[testenv:flake8] +basepython = python +deps = flake8 +commands = flake8 cookietemple + +[testenv] +setenv = + PYTHONPATH = {toxinidir} +deps = + -r{toxinidir}/requirements_dev.txt +; If you want to make tox run the tests with the same versions, create a +; requirements.txt with the pinned versions and uncomment the following line: +; -r{toxinidir}/requirements.txt +commands = + pip install -U pip + pytest --basetemp={envtmpdir} + From 69f23ffccad15fad5cc6280adbb9fce97ac441a9 Mon Sep 17 00:00:00 2001 From: zethson Date: Mon, 7 Dec 2020 18:43:34 +0000 Subject: [PATCH 02/20] Cookietemple sync --- .cookietemple.yml | 20 +++++++++-------- .github/workflows/build_package.yml | 2 +- .github/workflows/run_bandit.yml | 5 ++++- .github/workflows/run_codecov.yml | 2 +- .github/workflows/run_flake8_linting.yml | 5 ++++- .github/workflows/run_tox_testsuite.yml | 2 +- .github/workflows/sync_project.yml | 6 ++--- AUTHORS.rst | 2 +- LICENSE | 28 ++++++++++++++---------- README.rst | 12 +++++----- cookietemple.cfg | 2 ++ cookietemple/__init__.py | 2 +- docs/conf.py | 6 ++--- docs/installation.rst | 8 +++---- setup.py | 10 ++++----- 15 files changed, 64 insertions(+), 48 deletions(-) diff --git a/.cookietemple.yml b/.cookietemple.yml index 1909fdb2..5269a609 100644 --- a/.cookietemple.yml +++ b/.cookietemple.yml @@ -1,20 +1,22 @@ -cookietemple_version: '1.2.2-SNAPSHOT # <>' +cookietemple_version: '1.2.2 # <>' domain: cli language: python project_slug: cookietemple project_slug_no_hyphen: cookietemple -template_version: '1.0.1 # <>' +template_version: '1.1.0 # <>' template_handle: cli-python -github_username: zethson -creator_github_username: zethson -is_github_repo: false +github_username: cookiejar +creator_github_username: Zethson +is_github_repo: true is_repo_private: false -is_github_orga: false -full_name: Lukas Heumos +is_github_orga: true +github_orga: cookiejar +full_name: Lukas Heumos, Philipp Ehmele email: lukas.heumos@posteo.net project_name: cookietemple -project_short_description: cookietemple. A cookietemple based . +project_short_description: A cookiecutter based project template creation tool supporting + several domains and languages with linting and template sync support. version: 1.2.2 -license: Apache2.0 +license: MIT command_line_interface: Click testing_library: pytest diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index dbe79a12..e2d9c0e0 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -1,6 +1,6 @@ name: Build cookietemple Package -on: [push] +on: [push, pull_request] jobs: build: diff --git a/.github/workflows/run_bandit.yml b/.github/workflows/run_bandit.yml index 4ba4d813..2de05a46 100644 --- a/.github/workflows/run_bandit.yml +++ b/.github/workflows/run_bandit.yml @@ -1,9 +1,12 @@ name: Run bandit -on: +on: push: paths: - "**/*.py" + pull_request: + paths: + - "**/*.py" jobs: build: diff --git a/.github/workflows/run_codecov.yml b/.github/workflows/run_codecov.yml index 3b2f5365..51081c37 100644 --- a/.github/workflows/run_codecov.yml +++ b/.github/workflows/run_codecov.yml @@ -1,5 +1,5 @@ name: Run Codecov -on: [push] +on: [push, pull_request] jobs: run: diff --git a/.github/workflows/run_flake8_linting.yml b/.github/workflows/run_flake8_linting.yml index 34df5f85..fdfe190d 100644 --- a/.github/workflows/run_flake8_linting.yml +++ b/.github/workflows/run_flake8_linting.yml @@ -1,9 +1,12 @@ name: Run flake8 linting -on: +on: push: paths: - "**/*.py" + pull_request: + paths: + - "**/*.py" jobs: build: diff --git a/.github/workflows/run_tox_testsuite.yml b/.github/workflows/run_tox_testsuite.yml index 8ef92bfc..0d188c92 100644 --- a/.github/workflows/run_tox_testsuite.yml +++ b/.github/workflows/run_tox_testsuite.yml @@ -1,6 +1,6 @@ name: Run cookietemple Tox Test Suite -on: [push] +on: [push, pull_request] jobs: test: diff --git a/.github/workflows/sync_project.yml b/.github/workflows/sync_project.yml index d290c9cd..89292a45 100644 --- a/.github/workflows/sync_project.yml +++ b/.github/workflows/sync_project.yml @@ -25,10 +25,10 @@ jobs: - uses: oleksiyrudenko/gha-git-credentials@v2 with: - name: 'zethson' + name: 'Zethson' email: 'lukas.heumos@posteo.net' - actor: 'zethson' + actor: 'Zethson' token: '${{ secrets.CT_SYNC_TOKEN}}' - name: Sync project - run: cookietemple sync . ${{ secrets.CT_SYNC_TOKEN }} zethson + run: cookietemple sync . ${{ secrets.CT_SYNC_TOKEN }} Zethson diff --git a/AUTHORS.rst b/AUTHORS.rst index 498fbb07..54ec09e7 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -5,7 +5,7 @@ Credits Development Lead ---------------- -* Lukas Heumos +* Lukas Heumos, Philipp Ehmele Contributors ------------ diff --git a/LICENSE b/LICENSE index b3420ca2..d228203d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,15 +1,21 @@ -Apache Software License 2.0 +MIT License -Copyright (c) 2020, Lukas Heumos +Copyright (c) 2020, Lukas Heumos, Philipp Ehmele -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 at +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -http://www.apache.org/licenses/LICENSE-2.0 +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -Unless required by applicable law or agreed to in writing, software -distributed 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 and -limitations under the License. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.rst b/README.rst index 4c027fb8..a39a17b7 100644 --- a/README.rst +++ b/README.rst @@ -2,12 +2,12 @@ cookietemple ============ -.. image:: https://github.com/zethson/cookietemple/workflows/Build%20cookietemple%20Package/badge.svg - :target: https://github.com/zethson/cookietemple/workflows/Build%20cookietemple%20Package/badge.svg +.. image:: https://github.com/cookiejar/cookietemple/workflows/Build%20cookietemple%20Package/badge.svg + :target: https://github.com/cookiejar/cookietemple/workflows/Build%20cookietemple%20Package/badge.svg :alt: Github Workflow Build cookietemple Status -.. image:: https://github.com/zethson/cookietemple/workflows/Run%20cookietemple%20Tox%20Test%20Suite/badge.svg - :target: https://github.com/zethson/cookietemple/workflows/Run%20cookietemple%20Tox%20Test%20Suite/badge.svg +.. image:: https://github.com/cookiejar/cookietemple/workflows/Run%20cookietemple%20Tox%20Test%20Suite/badge.svg + :target: https://github.com/cookiejar/cookietemple/workflows/Run%20cookietemple%20Tox%20Test%20Suite/badge.svg :alt: Github Workflow Tests Status .. image:: https://img.shields.io/pypi/v/cookietemple.svg @@ -24,10 +24,10 @@ cookietemple :alt: Dependabot Enabled -cookietemple. A cookietemple based . +A cookiecutter based project template creation tool supporting several domains and languages with linting and template sync support. -* Free software: Apache2.0 +* Free software: MIT * Documentation: https://cookietemple.readthedocs.io. diff --git a/cookietemple.cfg b/cookietemple.cfg index dd9d5714..089063de 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -14,3 +14,5 @@ ct_sync_level = minor [sync_files_blacklisted] changelog = CHANGELOG.rst +requirements = requirements.txt +requirements_dev = requirements_dev.txt diff --git a/cookietemple/__init__.py b/cookietemple/__init__.py index d95f6f26..a78bc462 100644 --- a/cookietemple/__init__.py +++ b/cookietemple/__init__.py @@ -1,5 +1,5 @@ """Top-level package for cookietemple.""" -__author__ = """Lukas Heumos""" +__author__ = """Lukas Heumos, Philipp Ehmele""" __email__ = 'lukas.heumos@posteo.net' __version__ = '1.2.2' diff --git a/docs/conf.py b/docs/conf.py index 10537bee..240963c9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,8 +45,8 @@ # General information about the project. project = 'cookietemple' -copyright = "2020, Lukas Heumos" -author = "Lukas Heumos" +copyright = "2020, Lukas Heumos, Philipp Ehmele" +author = "Lukas Heumos, Philipp Ehmele" # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout @@ -127,7 +127,7 @@ latex_documents = [ (master_doc, 'cookietemple.tex', 'cookietemple Documentation', - 'Lukas Heumos', 'manual'), + 'Lukas Heumos, Philipp Ehmele', 'manual'), ] diff --git a/docs/installation.rst b/docs/installation.rst index 2444d44b..4387bfba 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -32,13 +32,13 @@ You can either clone the public repository: .. code-block:: console - $ git clone git://github.com/zethson/cookietemple + $ git clone git://github.com/cookiejar/cookietemple Or download the `tarball`_: .. code-block:: console - $ curl -OJL https://github.com/zethson/cookietemple/tarball/master + $ curl -OJL https://github.com/cookiejar/cookietemple/tarball/master Once you have a copy of the source, you can install it with: @@ -47,5 +47,5 @@ Once you have a copy of the source, you can install it with: $ make install -.. _Github repo: https://github.com/zethson/cookietemple -.. _tarball: https://github.com/zethson/cookietemple/tarball/master +.. _Github repo: https://github.com/cookiejar/cookietemple +.. _tarball: https://github.com/cookiejar/cookietemple/tarball/master diff --git a/setup.py b/setup.py index e5eeb89c..62f2fccb 100644 --- a/setup.py +++ b/setup.py @@ -37,26 +37,26 @@ def walker(base, *paths): test_requirements = ['pytest>=3', ] setup( - author="Lukas Heumos", + author="Lukas Heumos, Philipp Ehmele", author_email='lukas.heumos@posteo.net', python_requires='>=3.7', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', + 'License :: OSI Approved :: MIT License', 'Natural Language :: English', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', ], - description="cookietemple. A cookietemple based .", + description="A cookiecutter based project template creation tool supporting several domains and languages with linting and template sync support.", entry_points={ 'console_scripts': [ 'cookietemple=cookietemple.cli:main', ], }, install_requires=requirements, - license="Apache2.0", + license="MIT", long_description=readme + '\n\n' + history, include_package_data=True, keywords='cookietemple', @@ -71,7 +71,7 @@ def walker(base, *paths): setup_requires=setup_requirements, test_suite='tests', tests_require=test_requirements, - url='https://github.com/zethson/cookietemple', + url='https://github.com/cookiejar/cookietemple', version='1.2.2', zip_safe=False, ) From 8fa455c43f36eb9bea5b52d4c8a8ee3d692d11b9 Mon Sep 17 00:00:00 2001 From: zethson Date: Mon, 7 Dec 2020 18:45:26 +0000 Subject: [PATCH 03/20] Cookietemple sync --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e7301c8e..23fec1f7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,7 +10,7 @@ This project adheres to `Semantic Versioning `_. **Added** -* Created the project using cookietemple version 1.2.2-SNAPSHOT +* Created the project using cookietemple version 1.2.2 **Fixed** From 0318942f8c8b0541fcd953f22a5a8f2bf705e7ab Mon Sep 17 00:00:00 2001 From: Zethson Date: Mon, 7 Dec 2020 20:11:57 +0100 Subject: [PATCH 04/20] merge conflicts Signed-off-by: Zethson --- tests/test_cookietemple.py | 51 -------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 tests/test_cookietemple.py diff --git a/tests/test_cookietemple.py b/tests/test_cookietemple.py deleted file mode 100644 index e71bcd5c..00000000 --- a/tests/test_cookietemple.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python - -"""Tests for `cookietemple` package.""" -import os - -import pytest - -from click.testing import CliRunner - -# from cookietemple import cookietemple -from cookietemple import cli - - -@pytest.fixture -def response(): - """Sample pytest fixture. - - See more at: http://doc.pytest.org/en/latest/fixture.html - """ - import requests - return requests.get('https://github.com/torvalds/linux') - - -def test_content(response): - """Sample pytest test function with the pytest fixture as an argument.""" - # from bs4 import BeautifulSoup - # assert 'GitHub' in BeautifulSoup(response.content).title.string - - -class UnixFS: - - @staticmethod - def rm(filename): - os.remove(filename) - - -def test_unix_fs(mocker): - mocker.patch('os.remove') - UnixFS.rm('file') - os.remove.assert_called_once_with('file') - - -def test_command_line_interface(): - """Test the CLI.""" - runner = CliRunner() - result = runner.invoke(cli.main) - assert result.exit_code == 0 - assert 'cookietemple.cli.main' in result.output - help_result = runner.invoke(cli.main, ['--help']) - assert help_result.exit_code == 0 - assert '--help Show this message and exit.' in help_result.output From 7048be0c11f3c2ea6e7a023976af5041b25493e1 Mon Sep 17 00:00:00 2001 From: Zethson Date: Mon, 7 Dec 2020 20:18:00 +0100 Subject: [PATCH 05/20] readded coc Signed-off-by: Zethson --- docs/code_of_conduct.rst | 81 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/docs/code_of_conduct.rst b/docs/code_of_conduct.rst index 96e0ba2f..78568a4e 100644 --- a/docs/code_of_conduct.rst +++ b/docs/code_of_conduct.rst @@ -1 +1,80 @@ -.. include:: ../CODE_OF_CONDUCT.rst +Contributor Covenant Code of Conduct +==================================== + +Our Pledge +------------- + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and +expression, level of experience, education, socio-economic status, nationality, +personal appearance, race, religion, or sexual identity and orientation. + +Our Standards +------------------ + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others’ private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + + +Our Responsibilities +---------------------- + +Maintainers are responsible for clarifying the standards of acceptable behavior +and are expected to take appropriate and fair corrective action in response to +any instances of unacceptable behavior. + +Maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +Scope +----------- + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +Enforcement +------------------- + +Instances of abusive, harassing, or otherwise unacceptable behavior may +be reported by opening an issue. The project team +will review and investigate all complaints, and will respond in a way +that it deems appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an +incident. Further details of specific enforcement policies may be posted +separately. + +Project maintainers who do not follow or enforce the Code of Conduct in +good faith may face temporary or permanent repercussions as determined +by other members of the project’s leadership. + +Attribution +------------------- + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html From f5c58f2ef3ae0a5488af74e44e81adf79bef84b2 Mon Sep 17 00:00:00 2001 From: Zethson Date: Mon, 7 Dec 2020 20:18:58 +0100 Subject: [PATCH 06/20] ct css Signed-off-by: Zethson --- docs/_static/custom_cookietemple.css | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/docs/_static/custom_cookietemple.css b/docs/_static/custom_cookietemple.css index 91814223..ff1006b2 100644 --- a/docs/_static/custom_cookietemple.css +++ b/docs/_static/custom_cookietemple.css @@ -108,24 +108,6 @@ div, span, code { background-color: #2D2E2F !important; } -<<<<<<< HEAD -.wy-menu-vertical li.toctree-l2.current a .toctree-expand { - background-color: #2D2E2F !important; - color: #FFFFFF !important; -} - -.wy-menu-vertical li.toctree-l2.current a:hover .toctree-expand { - background-color: #005fff !important; - color: #FFFFFF !important; -} - -.wy-menu-vertical li.toctree-l3.current a .toctree-expand { - background-color: #2D2E2F !important; - color: #FFFFFF !important; -} - -======= ->>>>>>> origin/TEMPLATE .wy-menu-vertical li.toctree-l3 a:hover span.toctree-expand { background-color: #005fff !important; } From f8b7a6515fd278aa155a01a6c5848b919b1699d3 Mon Sep 17 00:00:00 2001 From: Imipenem Date: Tue, 8 Dec 2020 21:59:52 +0100 Subject: [PATCH 07/20] Example fix for working blacklisted files --- cookietemple/sync/sync.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cookietemple/sync/sync.py b/cookietemple/sync/sync.py index 43ebb64c..4812e36d 100644 --- a/cookietemple/sync/sync.py +++ b/cookietemple/sync/sync.py @@ -196,6 +196,10 @@ def commit_template_changes(self): # git add only non-blacklisted files print('[bold blue]Staging template.') self.repo.git.add(A=True) + Popen(['git', 'reset', 'requirements.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) + Popen(['git', 'reset', 'requirements_dev.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) + Popen(['git', 'checkout', '--' 'requirements.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) + Popen(['git', 'checkout', '--', 'requirements_dev.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) changed_files = [item.a_path for item in self.repo.index.diff('HEAD')] globs = self.get_blacklisted_sync_globs() blacklisted_changed_files = [] @@ -210,11 +214,12 @@ def commit_template_changes(self): files_to_commit = [file for file in changed_files if file not in blacklisted_changed_files] log.debug(f'Files to commit are:{nl}{nl.join(file for file in files_to_commit)}' if files_to_commit else 'No files to commit found.') - Popen(['git', 'commit', '-m', 'Cookietemple sync', *files_to_commit], stdout=PIPE, stderr=PIPE, universal_newlines=True) - print('[bold blue]Stashing and saving TEMPLATE branch changes!') - Popen(['git', 'stash'], stdout=PIPE, stderr=PIPE, universal_newlines=True) - self.made_changes = True - print('[bold blue]Committed changes to TEMPLATE branch') + if files_to_commit: + Popen(['git', 'commit', '-m', 'Cookietemple sync', *files_to_commit], stdout=PIPE, stderr=PIPE, universal_newlines=True) + print('[bold blue]Stashing and saving TEMPLATE branch changes!') + Popen(['git', 'stash'], stdout=PIPE, stderr=PIPE, universal_newlines=True) + self.made_changes = True + print('[bold blue]Committed changes to TEMPLATE branch') except Exception as e: print(f'[bold red]Could not commit changes to TEMPLATE:\n{e}') sys.exit(1) From ede75a63e2492fd6fb06e9b6f4ed96724066c2d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Dec 2020 04:13:56 +0000 Subject: [PATCH 08/20] [DEPENDABOT]: Bump cryptography from 3.2.1 to 3.3 Bumps [cryptography](https://github.com/pyca/cryptography) from 3.2.1 to 3.3. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/3.2.1...3.3) Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cd9e1caf..971fdf04 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ pygithub==1.53 GitPython==3.1.11 autopep8==1.5.4 cffi==1.14.4 -cryptography==3.2.1 +cryptography==3.3 requests==2.25.0 rich==9.3.0 packaging==20.7 From 2c3581b4aca9ded016deefa8cfe0959af382453f Mon Sep 17 00:00:00 2001 From: Zethson Date: Wed, 9 Dec 2020 09:32:36 +0100 Subject: [PATCH 09/20] add complete css to CT and common files Signed-off-by: Zethson --- .../docs/_static/custom_cookietemple.css | 44 +++++++++++++++++++ docs/_static/custom_cookietemple.css | 44 +++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/cookietemple/create/templates/common_files/{{cookiecutter.commonName}}/docs/_static/custom_cookietemple.css b/cookietemple/create/templates/common_files/{{cookiecutter.commonName}}/docs/_static/custom_cookietemple.css index ff1006b2..116126b6 100644 --- a/cookietemple/create/templates/common_files/{{cookiecutter.commonName}}/docs/_static/custom_cookietemple.css +++ b/cookietemple/create/templates/common_files/{{cookiecutter.commonName}}/docs/_static/custom_cookietemple.css @@ -13,6 +13,24 @@ div, span, code { background-color: #005fff !important; } +.wy-side-nav-search form { + background-color: #005fff !important; +} + +.wy-side-nav-search .wy-form input { + background-color: #2D2E2F !important; +} + +.wy-side-nav-search .wy-form input:focus { + background-color: #FFFFFF !important; + color: #000000 !important; +} + +::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: white; + opacity: 1; /* Firefox */ +} + /*Font color is mainly white*/ .rst-content p, li, h1, h2, h3, h4, h5, h6, .highlight-console, .n, .section { color: #FFFFFF; @@ -63,6 +81,17 @@ div, span, code { background: #005fff !important; } +.wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a { + color: #FFFFFF !important; + background: #2D2E2F !important; +} + +.wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a:hover { + color: #FFFFFF !important; + background: #005fff !important; +} + + .wy-menu-vertical li.toctree-l2.current > a:hover { color: #FFFFFF !important; background: #005fff !important; @@ -108,6 +137,21 @@ div, span, code { background-color: #2D2E2F !important; } +.wy-menu-vertical li.toctree-l2.current a .toctree-expand { + background-color: #2D2E2F !important; + color: #FFFFFF !important; +} + +.wy-menu-vertical li.toctree-l2.current a:hover .toctree-expand { + background-color: #005fff !important; + color: #FFFFFF !important; +} + +.wy-menu-vertical li.toctree-l3.current a .toctree-expand { + background-color: #2D2E2F !important; + color: #FFFFFF !important; +} + .wy-menu-vertical li.toctree-l3 a:hover span.toctree-expand { background-color: #005fff !important; } diff --git a/docs/_static/custom_cookietemple.css b/docs/_static/custom_cookietemple.css index ff1006b2..116126b6 100644 --- a/docs/_static/custom_cookietemple.css +++ b/docs/_static/custom_cookietemple.css @@ -13,6 +13,24 @@ div, span, code { background-color: #005fff !important; } +.wy-side-nav-search form { + background-color: #005fff !important; +} + +.wy-side-nav-search .wy-form input { + background-color: #2D2E2F !important; +} + +.wy-side-nav-search .wy-form input:focus { + background-color: #FFFFFF !important; + color: #000000 !important; +} + +::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ + color: white; + opacity: 1; /* Firefox */ +} + /*Font color is mainly white*/ .rst-content p, li, h1, h2, h3, h4, h5, h6, .highlight-console, .n, .section { color: #FFFFFF; @@ -63,6 +81,17 @@ div, span, code { background: #005fff !important; } +.wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a { + color: #FFFFFF !important; + background: #2D2E2F !important; +} + +.wy-menu-vertical li.toctree-l3.current li.toctree-l4 > a:hover { + color: #FFFFFF !important; + background: #005fff !important; +} + + .wy-menu-vertical li.toctree-l2.current > a:hover { color: #FFFFFF !important; background: #005fff !important; @@ -108,6 +137,21 @@ div, span, code { background-color: #2D2E2F !important; } +.wy-menu-vertical li.toctree-l2.current a .toctree-expand { + background-color: #2D2E2F !important; + color: #FFFFFF !important; +} + +.wy-menu-vertical li.toctree-l2.current a:hover .toctree-expand { + background-color: #005fff !important; + color: #FFFFFF !important; +} + +.wy-menu-vertical li.toctree-l3.current a .toctree-expand { + background-color: #2D2E2F !important; + color: #FFFFFF !important; +} + .wy-menu-vertical li.toctree-l3 a:hover span.toctree-expand { background-color: #005fff !important; } From 0c547e611e2a76f2505333929c5bb2a4607331d2 Mon Sep 17 00:00:00 2001 From: Zethson Date: Wed, 9 Dec 2020 09:34:09 +0100 Subject: [PATCH 10/20] delete unnecessary files & add docs/tests to blacklisted ifles Signed-off-by: Zethson --- cookietemple.cfg | 2 ++ docs/authors.rst | 1 - docs/modules.rst | 6 ------ tests/__init__.py | 1 - 4 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 docs/authors.rst delete mode 100644 docs/modules.rst delete mode 100644 tests/__init__.py diff --git a/cookietemple.cfg b/cookietemple.cfg index 089063de..7e0d0877 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -16,3 +16,5 @@ ct_sync_level = minor changelog = CHANGELOG.rst requirements = requirements.txt requirements_dev = requirements_dev.txt +tests = tests +docs = docs diff --git a/docs/authors.rst b/docs/authors.rst deleted file mode 100644 index e122f914..00000000 --- a/docs/authors.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../AUTHORS.rst diff --git a/docs/modules.rst b/docs/modules.rst deleted file mode 100644 index 28d3e8c1..00000000 --- a/docs/modules.rst +++ /dev/null @@ -1,6 +0,0 @@ -======= -Modules -======= - -.. automodapi:: cookietemple.cookietemple - diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index 5f3a82dd..00000000 --- a/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Unit test package for cookietemple.""" From f24624600672b0b56be59c320fc2f1dc697364c5 Mon Sep 17 00:00:00 2001 From: Zethson Date: Wed, 9 Dec 2020 09:36:29 +0100 Subject: [PATCH 11/20] readded __init__.py for tests Signed-off-by: Zethson --- tests/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b From 000a63485b98d083e67d0ecaa612b876df8d3d3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Dec 2020 04:13:13 +0000 Subject: [PATCH 12/20] [DEPENDABOT]: Bump cryptography from 3.3 to 3.3.1 Bumps [cryptography](https://github.com/pyca/cryptography) from 3.3 to 3.3.1. - [Release notes](https://github.com/pyca/cryptography/releases) - [Changelog](https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/3.3...3.3.1) Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 971fdf04..3c483ca8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ pygithub==1.53 GitPython==3.1.11 autopep8==1.5.4 cffi==1.14.4 -cryptography==3.3 +cryptography==3.3.1 requests==2.25.0 rich==9.3.0 packaging==20.7 From 6376318d1d7992643410d5bbb5cb8a12abc92802 Mon Sep 17 00:00:00 2001 From: Imipenem Date: Fri, 11 Dec 2020 22:30:24 +0100 Subject: [PATCH 13/20] [FIX] Fixed sync command - blacklisted files are now reseted to its original form, so they will never appear in a PR or marked as modified by git local - before creating a new sync pull request, cookietemple queries all PRs to check, whether there is an already open sync PR ==> if yes, the old PR will be closed - the PR will now be made from a temporary branch, only for this sync, so the TEMPLATE branch will be pushed but never touched (or merged) --- cookietemple/sync/sync.py | 67 ++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/cookietemple/sync/sync.py b/cookietemple/sync/sync.py index 4812e36d..094b2965 100644 --- a/cookietemple/sync/sync.py +++ b/cookietemple/sync/sync.py @@ -9,7 +9,7 @@ from distutils.dir_util import copy_tree from subprocess import Popen, PIPE from typing import Tuple - +from github import Github import git # type: ignore import json import os @@ -195,31 +195,41 @@ def commit_template_changes(self): try: # git add only non-blacklisted files print('[bold blue]Staging template.') + # add all files to stage self.repo.git.add(A=True) - Popen(['git', 'reset', 'requirements.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) - Popen(['git', 'reset', 'requirements_dev.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) - Popen(['git', 'checkout', '--' 'requirements.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) - Popen(['git', 'checkout', '--', 'requirements_dev.txt'], stdout=PIPE, stderr=PIPE, universal_newlines=True) + # get all changed/modified files during the sync (including blacklisted ones) changed_files = [item.a_path for item in self.repo.index.diff('HEAD')] globs = self.get_blacklisted_sync_globs() - blacklisted_changed_files = [] + blacklisted_changed_files = set() for pattern in globs: # keep track of all staged files matching a glob from the cookietemple.cfg file # those files will be excluded from syncing but will still be available in every new created projects - blacklisted_changed_files += fnmatch.filter(changed_files, pattern) + blacklisted_changed_files |= {file for file in fnmatch.filter(changed_files, pattern)} nl = '\n' log.debug(f'Blacklisted (unsynced) files are:{nl}{nl.join(file for file in blacklisted_changed_files)}' if blacklisted_changed_files else 'No blacklisted files for syncing found.') - print('[bold blue]Committing changes of non blacklisted files.') + # each blacklisted file must be first unstaged and then get its changes discarded, so it will not be marked as modified by git + for blacklisted_file in blacklisted_changed_files: + log.debug(f'Unstaging {blacklisted_file}') + Popen(['git', 'reset', blacklisted_file], stdout=PIPE, stderr=PIPE, universal_newlines=True) + log.debug(f'Discarding changes in working directory of file {blacklisted_file}') + Popen(['git', 'checkout', '--', blacklisted_file], stdout=PIPE, stderr=PIPE, universal_newlines=True) + files_to_commit = [file for file in changed_files if file not in blacklisted_changed_files] log.debug(f'Files to commit are:{nl}{nl.join(file for file in files_to_commit)}' if files_to_commit else 'No files to commit found.') if files_to_commit: + print('[bold blue]Committing changes of non blacklisted files.') Popen(['git', 'commit', '-m', 'Cookietemple sync', *files_to_commit], stdout=PIPE, stderr=PIPE, universal_newlines=True) print('[bold blue]Stashing and saving TEMPLATE branch changes!') Popen(['git', 'stash'], stdout=PIPE, stderr=PIPE, universal_newlines=True) self.made_changes = True print('[bold blue]Committed changes to TEMPLATE branch') + + # if a file was added to the template, but is blacklisted, it remains untracked; so it should be removed + for untracked_file in self.repo.untracked_files: + log.debug(f'Removing untracked file {untracked_file}') + Path(untracked_file).unlink() except Exception as e: print(f'[bold red]Could not commit changes to TEMPLATE:\n{e}') sys.exit(1) @@ -227,8 +237,8 @@ def commit_template_changes(self): def push_template_branch(self): """ - If we made any changes, push the TEMPLATE branch to the default remote - and try to make a PR. + If there are any changes to the template, push the TEMPLATE branch to the default remote + and push to the actual sync temporary branch, where a PR is actually created from to development branch. """ print(f'[bold blue]Pushing TEMPLATE branch to remote: {os.path.basename(self.project_dir)}') try: @@ -238,13 +248,19 @@ def push_template_branch(self): self.repo.head.ref.set_tracking_branch(origin.refs.TEMPLATE) log.debug('Pushing to upstream branch TEMPLATE.') self.repo.git.push(force=True) + print(f'[bold blue]Checking out to new branch cookietemple_sync_v{self.new_template_version}') + log.debug(f'git checkout -b cookietemple_sync_v{self.new_template_version}') + self.repo.git.checkout('-b', f'cookietemple_sync_v{self.new_template_version}') + log.debug(f'git push origin cookietemple_sync_v{self.new_template_version}') + print(f'[bold blue]Pushing to remote branch cookietemple_sync_v{self.new_template_version}') + self.repo.remotes.origin.push(refspec=f'cookietemple_sync_v{self.new_template_version}:cookietemple_sync_v{self.new_template_version}') except git.exc.GitCommandError as e: - print(f'Could not push TEMPLATE branch:\n{e}') + print(f'Could not push TEMPLATE or cookietemple_sync_v{self.new_template_version} branch:\n{e}') sys.exit(1) def make_pull_request(self): """ - Create a pull request to a base branch from a head branch (default: TEMPLATE) + Create a pull request to a base branch from a head branch (that is, a temporary branch only created for syncing the new template version) """ log.debug('Preparing PR contents to submit a sync PR.') if self.dot_cookietemple['is_github_orga']: @@ -258,11 +274,10 @@ def make_pull_request(self): 'For more information on the actual changes, read the latest cookietemple changelog.') log.debug(f'PR title is {pr_title} and PR body: {pr_body_text}') - # Only create PR if it does not already exist - if not self.check_pull_request_exists(): - self.submit_pull_request(pr_title, pr_body_text) - else: - print('[bold blue]An open cookietemple sync PR already exists at your repo. Changes were added to the existing PR!') + # Check, whether a cookietemple sync PR is already open + self.check_pull_request_exists() + # Submit the new pull request with the latest cookietemple sync changes + self.submit_pull_request(pr_title, pr_body_text) def submit_pull_request(self, pr_title, pr_body_text): """ @@ -272,7 +287,7 @@ def submit_pull_request(self, pr_title, pr_body_text): 'title': pr_title, 'body': pr_body_text, 'maintainer_can_modify': True, - 'head': 'TEMPLATE', + 'head': f'cookietemple_sync_v{self.new_template_version}', 'base': 'development', } log.debug(f'Trying to submit a sync PR to https://api.github.com/repos/{self.repo_owner}/{self.dot_cookietemple["project_slug"]}/pulls') @@ -299,21 +314,21 @@ def submit_pull_request(self, pr_title, pr_body_text): def check_pull_request_exists(self) -> bool: """ - Check, if a cookietemple sync PR is already pending. If so, just push changes and do not create a new PR! + Check, whether a cookietemple sync PR is already open. If so, close this one, as it is outdated. :return Whether a cookietemple sync PR is already open or not """ - query_url = f'https://api.github.com/repos/{self.repo_owner}/{self.dot_cookietemple["project_slug"]}/pulls?state=open' - headers = {'Authorization': f'token {self.token}'} + g = Github(self.token) + repo = g.get_repo(f'{self.repo_owner}/{self.dot_cookietemple["project_slug"]}') # query all open PRs log.debug('Querying open PRs to check if a sync PR already exists.') - r = requests.get(query_url, headers=headers) - query_data = r.json() - log.debug(f'Query returned: {query_data}') # iterate over the open PRs of the repo to check if a cookietemple sync PR is open - for pull_request in query_data: + for pull_request in repo.get_pulls(state='open'): log.debug('Already open sync PR has been found.') - if 'Important cookietemple template update' in pull_request['title']: + # if an older, outdated cookietemple sync PR is still open, close it first + if 'Important cookietemple template update' in pull_request.title: + print('[bold blue]Detected open, but outdated cookietemple sync PR. Closing it in favor of the newest sync PR!') + pull_request.edit(state='closed') return True return False From f1580ca90ebbb71dc665699dfd88c1ee4166b786 Mon Sep 17 00:00:00 2001 From: Imipenem Date: Fri, 11 Dec 2020 22:40:03 +0100 Subject: [PATCH 14/20] Added missing blacklisted sync section - missed requirements.txt and requirements_dev.txt --- cookietemple.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cookietemple.cfg b/cookietemple.cfg index 83631e48..e951a540 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -14,4 +14,6 @@ ct_sync_level = patch [sync_files_blacklisted] changelog = CHANGELOG.rst +requirements = requirements.txt +requirements_dev = requirements_dev.txt From dbc9c255c4d0d085c59f50496e04c0fa90c035d1 Mon Sep 17 00:00:00 2001 From: Imipenem Date: Fri, 11 Dec 2020 23:00:41 +0100 Subject: [PATCH 15/20] Added tests and docs dirs to blacklisted sync files --- cookietemple.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cookietemple.cfg b/cookietemple.cfg index e951a540..fd909235 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -16,4 +16,6 @@ ct_sync_level = patch changelog = CHANGELOG.rst requirements = requirements.txt requirements_dev = requirements_dev.txt +tests = tests/**/* +docs = docs/**/* From f54c1964e8662acbf8523a96ba61aa66a633705f Mon Sep 17 00:00:00 2001 From: Imipenem Date: Sat, 12 Dec 2020 23:01:59 +0100 Subject: [PATCH 16/20] Bump version from 1.2.2 to 1.2.3-SNAPSHOT --- .cookietemple.yml | 2 +- CHANGELOG.rst | 12 ++++++++++++ cookietemple.cfg | 2 +- cookietemple/__init__.py | 2 +- docs/conf.py | 4 ++-- setup.py | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.cookietemple.yml b/.cookietemple.yml index 3212bb64..ea962e46 100644 --- a/.cookietemple.yml +++ b/.cookietemple.yml @@ -7,7 +7,7 @@ project_name: cookietemple project_slug: cookietemple project_slug_no_hyphen: cookietemple project_short_description: A cookiecutter based project template creation tool supporting several domains and languages with linting and template sync support. -version: 1.2.2 +version: 1.2.3-SNAPSHOT license: MIT github_username: cookiejar creator_github_username: Zethson diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 395f2cc2..56778cf2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,18 @@ Changelog This project adheres to `Semantic Versioning `_. +1.2.3-SNAPSHOT (2020-12-12) +--------------------------- + +**Added** + +**Fixed** + +**Dependencies** + +**Deprecated** + + 1.2.2 (2020-12-06) ------------------ diff --git a/cookietemple.cfg b/cookietemple.cfg index fd909235..ce13fa44 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.2.2 +current_version = 1.2.3-SNAPSHOT [bumpversion_files_whitelisted] init_file = cookietemple/__init__.py diff --git a/cookietemple/__init__.py b/cookietemple/__init__.py index 9c1e4556..42c8abce 100644 --- a/cookietemple/__init__.py +++ b/cookietemple/__init__.py @@ -7,4 +7,4 @@ # __version__ = metadata.version('cookietemple') -__version__ = '1.2.2' +__version__ = '1.2.3-SNAPSHOT' diff --git a/docs/conf.py b/docs/conf.py index c08479f4..9b428f0a 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,8 +21,8 @@ copyright = u'2020, Lukas Heumos, Philipp Ehmele, the cookiejar organization' author = u'Lukas Heumos, Philipp Ehmele, the cookiejar organization' -version = '1.2.2' -release = '1.2.2' +version = '1.2.3-SNAPSHOT' +release = '1.2.3-SNAPSHOT' language = None diff --git a/setup.py b/setup.py index 6bf24191..720bdd3a 100644 --- a/setup.py +++ b/setup.py @@ -78,6 +78,6 @@ def walker(base: str, *paths) -> list: test_suite='tests', tests_require=test_requirements, url='https://github.com/cookiejar/cookietemple', - version='1.2.2', + version='1.2.3-SNAPSHOT', zip_safe=False, ) From 9511d2e475820be08bb3b27e2e3e67175546466b Mon Sep 17 00:00:00 2001 From: Imipenem Date: Sat, 12 Dec 2020 23:05:55 +0100 Subject: [PATCH 17/20] Updated Changelog --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 56778cf2..3afad663 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,8 +11,13 @@ This project adheres to `Semantic Versioning `_. **Added** +* the sync PR is now always created from a new, temporary sync branch and not from TEMPLATE branch anymore + **Fixed** +* fixed a bug, that causes blacklisted files to be synced +* fixed a bug, where changes made to blacklisted files during sync were not discarded + **Dependencies** **Deprecated** From 60504a0f46688b2c1ec45cf9ddc69fded2b34ff1 Mon Sep 17 00:00:00 2001 From: Imipenem Date: Sat, 12 Dec 2020 23:13:26 +0100 Subject: [PATCH 18/20] Merge fixes --- cookietemple/__init__.py | 9 --------- cookietemple/sync/sync.py | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/cookietemple/__init__.py b/cookietemple/__init__.py index 42c8abce..4d1d0844 100644 --- a/cookietemple/__init__.py +++ b/cookietemple/__init__.py @@ -1,10 +1 @@ -# -*- coding: utf-8 -*- -# try: -# from importlib import metadata -# except ImportError: -# Running on pre-3.8 Python; use importlib-metadata package -# import importlib_metadata as metadata - -# __version__ = metadata.version('cookietemple') - __version__ = '1.2.3-SNAPSHOT' diff --git a/cookietemple/sync/sync.py b/cookietemple/sync/sync.py index 094b2965..52a13054 100644 --- a/cookietemple/sync/sync.py +++ b/cookietemple/sync/sync.py @@ -220,7 +220,7 @@ def commit_template_changes(self): 'No files to commit found.') if files_to_commit: print('[bold blue]Committing changes of non blacklisted files.') - Popen(['git', 'commit', '-m', 'Cookietemple sync', *files_to_commit], stdout=PIPE, stderr=PIPE, universal_newlines=True) + Popen(['git', 'commit', '-m', 'cookietemple sync', *files_to_commit], stdout=PIPE, stderr=PIPE, universal_newlines=True) print('[bold blue]Stashing and saving TEMPLATE branch changes!') Popen(['git', 'stash'], stdout=PIPE, stderr=PIPE, universal_newlines=True) self.made_changes = True From bd2ae72f3cff2f7ac07dfd87aa67f484e5d0a901 Mon Sep 17 00:00:00 2001 From: Imipenem Date: Sun, 13 Dec 2020 16:00:46 +0100 Subject: [PATCH 19/20] [Fix #551] Fixed failing project creation with path specified --- CHANGELOG.rst | 1 + cookietemple/create/template_creator.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3afad663..b3159f80 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,7 @@ This project adheres to `Semantic Versioning `_. * fixed a bug, that causes blacklisted files to be synced * fixed a bug, where changes made to blacklisted files during sync were not discarded +* fixed a bug, when creating a project with a path parameter named like the project caused a move **Dependencies** diff --git a/cookietemple/create/template_creator.py b/cookietemple/create/template_creator.py index 37cb0496..92f326fd 100644 --- a/cookietemple/create/template_creator.py +++ b/cookietemple/create/template_creator.py @@ -84,7 +84,9 @@ def process_common_operations(self, path: Path, skip_common_files=False, skip_fi console.print('[bold blue]Please visit: https://cookietemple.readthedocs.io/en/latest/available_templates/available_templates.html' f'#{domain}-{language} for more information about how to use your chosen template.') - if path != Path.cwd(): + cwd = Path.cwd() + # do not move if path is current working directory or a directory named like the project in the current working directory (second is default case) + if path != cwd and path != Path(cwd/self.creator_ctx.project_slug_no_hyphen): shutil.move(f'{Path.cwd()}/{self.creator_ctx.project_slug_no_hyphen}', f'{path}/{self.creator_ctx.project_slug_no_hyphen}') def create_template_without_subdomain(self, domain_path: str) -> None: From 0f6cc5be15c87fdfbc361acf53dbd9ca70d78948 Mon Sep 17 00:00:00 2001 From: Zethson Date: Sun, 13 Dec 2020 17:21:05 +0100 Subject: [PATCH 20/20] Bump version from 1.2.3-SNAPSHOT to 1.2.3 --- .cookietemple.yml | 2 +- CHANGELOG.rst | 4 ++-- cookietemple.cfg | 5 +++-- cookietemple/__init__.py | 2 +- docs/conf.py | 4 ++-- setup.py | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.cookietemple.yml b/.cookietemple.yml index a1df479c..5557af91 100644 --- a/.cookietemple.yml +++ b/.cookietemple.yml @@ -4,7 +4,7 @@ language: python project_slug: cookietemple project_slug_no_hyphen: cookietemple project_short_description: A cookiecutter based project template creation tool supporting several domains and languages with linting and template sync support. -version: 1.2.3-SNAPSHOT +version: 1.2.3 license: Apache2.0 template_version: '1.1.0 # <>' template_handle: cli-python diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b3159f80..5f8c35e9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,8 +6,8 @@ Changelog This project adheres to `Semantic Versioning `_. -1.2.3-SNAPSHOT (2020-12-12) ---------------------------- +1.2.3 (2020-12-13) +------------------ **Added** diff --git a/cookietemple.cfg b/cookietemple.cfg index abd1e584..90d5e988 100644 --- a/cookietemple.cfg +++ b/cookietemple.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.2.3-SNAPSHOT +current_version = 1.2.3 [bumpversion_files_whitelisted] setup_file = setup.py @@ -17,4 +17,5 @@ changelog = CHANGELOG.rst requirements = requirements.txt requirements_dev = requirements_dev.txt tests = tests/**/* -docs = docs/**/* \ No newline at end of file +docs = docs/**/* + diff --git a/cookietemple/__init__.py b/cookietemple/__init__.py index 4d1d0844..5a5df3be 100644 --- a/cookietemple/__init__.py +++ b/cookietemple/__init__.py @@ -1 +1 @@ -__version__ = '1.2.3-SNAPSHOT' +__version__ = '1.2.3' diff --git a/docs/conf.py b/docs/conf.py index d09e5db1..65f41752 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,8 +21,8 @@ copyright = u'2020, Lukas Heumos, Philipp Ehmele, the cookiejar organization' author = u'Lukas Heumos, Philipp Ehmele, the cookiejar organization' -version = '1.2.3-SNAPSHOT' -release = '1.2.3-SNAPSHOT' +version = '1.2.3' +release = '1.2.3' language = None diff --git a/setup.py b/setup.py index 720bdd3a..0574d3db 100644 --- a/setup.py +++ b/setup.py @@ -78,6 +78,6 @@ def walker(base: str, *paths) -> list: test_suite='tests', tests_require=test_requirements, url='https://github.com/cookiejar/cookietemple', - version='1.2.3-SNAPSHOT', + version='1.2.3', zip_safe=False, )