diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 8a42c2d..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug -assignees: '' - ---- - -* Date you used Cookiecutter NetBox plugin: -* Cookiecutter version used, if any: -* Python version, if any: -* Operating System: - -### Description - -Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen. - -### What I Did - -``` -Paste the command(s) you ran and the output. -``` diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..7fe4f3e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,54 @@ +--- +name: 🐛 Bug Report +description: Report a reproducible bug in the current release of cookiecutter-netbox-plugin +labels: ["type: bug"] +body: + - type: markdown + attributes: + value: > + **NOTE:** This form is only for reporting _reproducible bugs_ in a current cookiecutter-netbox-plugin release. + - type: input + attributes: + label: cookiecutter-netbox-plugin version + description: What version of cookiecutter-netbox-plugin are you currently running? + placeholder: v0.1.0 + validations: + required: true + - type: dropdown + attributes: + label: Python version + description: What version of Python are you currently running? + options: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + validations: + required: true + - type: textarea + attributes: + label: Steps to Reproduce + description: > + Please provide a minimal working example to demonstrate the bug. Begin with the + initialization of any necessary database objects and clearly enumerate each + operation carried out. Ensure that your example is as concise as possible + while adequately illustrating the issue. + + _Please refrain from including any confidential or sensitive + information in your example._ + validations: + required: true + - type: textarea + attributes: + label: Expected Behavior + description: What did you expect to happen? + placeholder: The script should execute without raising any errors or exceptions + validations: + required: true + - type: textarea + attributes: + label: Observed Behavior + description: What happened instead? + placeholder: A TypeError exception was raised + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..d852cac --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,12 @@ +# Reference: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser +blank_issues_enabled: false +contact_links: + - name: 📖 Contributing Policy + url: https://github.com/netbox-community/cookiecutter-netbox-plugin/blob/main/CONTRIBUTING.md + about: "Please read through our contributing policy before opening an issue or pull request." + - name: ❓ Discussion + url: https://github.com/netbox-community/cookiecutter-netbox-plugin/discussions + about: "If you're just looking for help, try starting a discussion instead." + - name: 💬 Community Slack + url: https://netdev.chat + about: "Join #netbox on the NetDev Community Slack for assistance with installation issues and other problems." diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 234ef25..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..bb6ec1a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,52 @@ +--- +name: ✨ Feature Request +description: Propose a new cookiecutter-netbox-plugin feature or enhancement +labels: ["type: feature"] +body: + - type: markdown + attributes: + value: > + **NOTE:** This form is only for submitting well-formed proposals to extend or modify + cookiecutter-netbox-plugin in some way. If you're trying to solve a problem but can't figure out how, or if + you still need time to work on the details of a proposed new feature, please start a + [discussion](https://github.com/netbox-community/pynetbox/discussions) instead. + - type: input + attributes: + label: cookiecutter-netbox-plugin version + description: What version of cookiecutter-netbox-plugin are you currently running? + placeholder: v0.1.0 + validations: + required: true + - type: dropdown + attributes: + label: Feature type + options: + - Data model extension + - New functionality + - Change to existing functionality + validations: + required: true + - type: textarea + attributes: + label: Proposed functionality + description: > + Describe in detail the new feature or behavior you are proposing. Include any specific changes + to work flows, data models, and/or the user interface. The more detail you provide here, the + greater chance your proposal has of being discussed. Feature requests which don't include an + actionable implementation plan will be rejected. + validations: + required: true + - type: textarea + attributes: + label: Use case + description: > + Explain how adding this functionality would benefit cookiecutter-netbox-plugin users. What need does it address? + validations: + required: true + - type: textarea + attributes: + label: External dependencies + description: > + List any new dependencies on external libraries or services that this new feature would + introduce. For example, does the proposal require the installation of a new Python package? + (Not all new features introduce new dependencies.) diff --git a/.github/ISSUE_TEMPLATE/housekeeping.yaml b/.github/ISSUE_TEMPLATE/housekeeping.yaml new file mode 100644 index 0000000..7778713 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/housekeeping.yaml @@ -0,0 +1,24 @@ +--- +name: 🏡 Housekeeping +description: A change pertaining to the codebase itself (developers only) +labels: ["type: housekeeping"] +body: + - type: markdown + attributes: + value: > + **NOTE:** This template is for use by maintainers only. Please do not submit + an issue using this template unless you have been specifically asked to do so. + - type: textarea + attributes: + label: Proposed Changes + description: > + Describe in detail the new feature or behavior you'd like to propose. + Include any specific changes to work flows, data models, or the user interface. + validations: + required: true + - type: textarea + attributes: + label: Justification + description: Please provide justification for the proposed change(s). + validations: + required: true diff --git a/.gitignore b/.gitignore index 61ee983..fa871cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,14 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class +# https://github.com/github/gitignore/blob/main/Global/macOS.gitignore -# OSX useful to ignore -*.DS_Store +# General +.DS_Store .AppleDouble .LSOverride +# Icon must end with two \r +Icon + + # Thumbnails ._* @@ -27,13 +28,112 @@ Network Trash Folder Temporary Items .apdisk +# https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# https://github.com/github/gitignore/blob/main/Python.gitignore + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + # C extensions *.so # Distribution / packaging .Python -env/ -venv/ build/ develop-eggs/ dist/ @@ -45,9 +145,12 @@ lib64/ parts/ sdist/ var/ +wheels/ +share/python-wheels/ *.egg-info/ .installed.cfg *.egg +MANIFEST # PyInstaller # Usually these files are written by a python script from a template @@ -62,14 +165,17 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ +.nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml -*,cover +*.cover +*.py,cover .hypothesis/ .pytest_cache/ +cover/ # Translations *.mo @@ -77,27 +183,97 @@ coverage.xml # Django stuff: *.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy # Sphinx documentation docs/_build/ -# IntelliJ Idea family of suites -.idea -*.iml -## File-based project format: -*.ipr -*.iws -## mpeltonen/sbt-idea plugin -.idea_modules/ - # PyBuilder +.pybuilder/ target/ -# Cookiecutter -output/ -python_boilerplate/ +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .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 + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__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/ -# IDE settings -.vscode/ +# pytype static type analyzer +.pytype/ -site/ +# Cython debug symbols +cython_debug/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f1b06a0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +ci: + autoupdate_commit_msg: "chore: update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: end-of-file-fixer + - id: mixed-line-ending + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/mgedmin/check-manifest + rev: "0.47" + hooks: + - id: check-manifest + stages: [manual] diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..94d5951 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 0.1.0 (2023-02-06) + +* First release on PyPI. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..9c41a18 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders 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, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[ahanson@netboxlabs.com](mailto:ahanson@netboxlabs.com). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/docs/history.md b/docs/history.md index c37fae2..7baf07f 100644 --- a/docs/history.md +++ b/docs/history.md @@ -1,5 +1,5 @@ # History - + ## v0.1.0 ***first (Beta) release with the following features:*** diff --git a/docs/index.md b/docs/index.md index e9047a6..925533a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,3 @@ {% include-markdown "../README.md" -%} \ No newline at end of file +%} diff --git a/docs/tutorial.md b/docs/tutorial.md index 33607de..1923a78 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -8,7 +8,7 @@ If you are new to Git and GitHub, you should probably spend a few minutes on some tutorials at the top of the page at [GitHub Help](https://help.github.com/). You will also need an installation of [NetBox](https://github.com/netbox-community/netbox) to configure and test the plugin. -More information on Plugin Development can be found in the NetBox documentation +More information on Plugin Development can be found in the NetBox documentation [Plugin Development](https://docs.netbox.dev/en/stable/plugins/development/). ## Step 1: Install Cookiecutter diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index c17c945..3ec29a7 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import annotations + import os PROJECT_DIRECTORY = os.path.realpath(os.path.curdir) @@ -8,7 +10,6 @@ def remove_file(filepath): os.remove(os.path.join(PROJECT_DIRECTORY, filepath)) -if __name__ == '__main__': - - if 'Not open source' == '{{ cookiecutter.open_source_license }}': - remove_file('LICENSE') +if __name__ == "__main__": + if "Not open source" == "{{ cookiecutter.open_source_license }}": + remove_file("LICENSE") diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 6d39400..2173bed 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -1,13 +1,17 @@ +from __future__ import annotations + import re import sys +MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]+$" -MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$' - -module_name = '{{ cookiecutter.project_slug}}' +module_name = "{{ cookiecutter.project_slug}}" if not re.match(MODULE_REGEX, module_name): - print('ERROR: The project slug (%s) is not a valid Python module name. Please do not use a - and use _ instead' % module_name) + print( + "ERROR: The project slug (%s) is not a valid Python module name. Please do not use a - and use _ instead" + % module_name + ) - #Exit to cancel project - sys.exit(1) \ No newline at end of file + # Exit to cancel project + sys.exit(1) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ec5a788 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,54 @@ +# See PEP 518 for the spec of this file +# https://www.python.org/dev/peps/pep-0518/ + +[build-system] +requires = ["setuptools>=63.2.0", "wheel"] + +[project] +name = "cookiecutter-netbox-plugin" +authors = [ + {name = "Arthur Hanson", email = "ahanson@netboxlabs.com"}, +] +description = "Cookiecutter template for a NetBox plugin" +readme = "README.md" + +classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Natural Language :: English', + "Programming Language :: Python :: 3 :: Only", + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', +] + +requires-python = ">=3.8" +dynamic = ["version"] + +[project.optional-dependencies] +test = [ + "black==23.3.0", + "check-manifest==0.49", + "pre-commit==3.3.1", + "pylint==2.17.4", + "pytest-mock<3.10.1", + "pytest-runner", + "pytest==7.3.1", + "pytest-github-actions-annotate-failures", +] + +[project.urls] +Documentation = "https://https://github.com/netbox-community/cookiecutter-netbox-plugin/blob/main/README.md" +Source = "https://https://github.com/netbox-community/cookiecutter-netbox-plugin" +Tracker = "https://github.com/netbox-community/cookiecutter-netbox-plugin/issues" + +[tool.black] +line-length = 120 +target_version = ['py38', 'py39', 'py310', 'py311'] + +[tool.isort] +profile = "black" + +[tool.pylint] +max-line-length = 120 diff --git a/requirements_dev.txt b/requirements_dev.txt index 7b67d47..7249de7 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,6 +1,6 @@ +black==23.9.1 +bump2version==1.0.1 +cookiecutter>=2.3.1 +isort==5.12.0 pytest==5.3.1 -tox==3.14.1 -cookiecutter>=1.4.0 pytest-cookies==0.5.1 -alabaster==0.7.12 -watchdog==0.9.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 68c462a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[bumpversion] -current_version = 0.1.0 -commit = True -tag = True - -[metadata] -description-file = README.md - -[bumpversion:file:setup.py] -search = version='{current_version}' -replace = version='{new_version}' diff --git a/setup.py b/setup.py deleted file mode 100644 index 8470346..0000000 --- a/setup.py +++ /dev/null @@ -1,30 +0,0 @@ -# !/usr/bin/env python - -from distutils.core import setup -setup( - name='cookiecutter-netbox-plugin', - packages=[], - version='0.1.0', - description='Cookiecutter template for a NetBox plugin', - author='Arthur Hanson', - license='BSD', - author_email='ahanson@netboxlabs.com', - url='https://github.com/netbox-community/cookiecutter-netbox-plugin', - keywords=['cookiecutter', 'template', 'package', 'netbox'], - python_requires='>=3.8', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Natural Language :: English', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Software Development', - ], -) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index f9562d4..6bb02ce 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -1,16 +1,17 @@ -from contextlib import contextmanager -import shlex +from __future__ import annotations + +import datetime +import importlib import os -import sys +import shlex import subprocess -import yaml -import datetime -import pytest -from cookiecutter.utils import rmtree +import sys +from contextlib import contextmanager +import pytest +import yaml from click.testing import CliRunner - -import importlib +from cookiecutter.utils import rmtree @contextmanager @@ -59,7 +60,7 @@ def check_output_inside_dir(command, dirpath): def test_year_compute_in_license_file(cookies): with bake_in_temp_dir(cookies) as result: - license_file_path = result.project.join('LICENSE') + license_file_path = result.project.join("LICENSE") now = datetime.datetime.now() assert str(now.year) in license_file_path.read() @@ -79,75 +80,64 @@ def test_bake_with_defaults(cookies): assert result.exception is None found_toplevel_files = [f.basename for f in result.project.listdir()] - assert 'setup.py' in found_toplevel_files - assert 'python_boilerplate' in found_toplevel_files - assert 'tests' in found_toplevel_files + assert "setup.py" in found_toplevel_files + assert "python_boilerplate" in found_toplevel_files + assert "tests" in found_toplevel_files def test_bake_and_run_tests(cookies): with bake_in_temp_dir(cookies) as result: assert result.project.isdir() - run_inside_dir('python setup.py test', str(result.project)) == 0 + run_inside_dir("python setup.py test", str(result.project)) == 0 print("test_bake_and_run_tests path", str(result.project)) def test_bake_withspecialchars_and_run_tests(cookies): """Ensure that a `full_name` with double quotes does not break setup.py""" with bake_in_temp_dir( - cookies, - extra_context={'full_name': 'name "quote" name'} + cookies, extra_context={"full_name": 'name "quote" name'} ) as result: assert result.project.isdir() - run_inside_dir('python setup.py test', str(result.project)) == 0 + run_inside_dir("python setup.py test", str(result.project)) == 0 def test_bake_with_apostrophe_and_run_tests(cookies): """Ensure that a `full_name` with apostrophes does not break setup.py""" - with bake_in_temp_dir( - cookies, - extra_context={'full_name': "O'connor"} - ) as result: + with bake_in_temp_dir(cookies, extra_context={"full_name": "O'connor"}) as result: assert result.project.isdir() - run_inside_dir('python setup.py test', str(result.project)) == 0 + run_inside_dir("python setup.py test", str(result.project)) == 0 def test_make_help(cookies): with bake_in_temp_dir(cookies) as result: # The supplied Makefile does not support win32 if sys.platform != "win32": - output = check_output_inside_dir( - 'make help', - str(result.project) - ) - assert b"check code coverage quickly with the default Python" in \ - output + output = check_output_inside_dir("make help", str(result.project)) + assert b"check code coverage quickly with the default Python" in output def test_bake_selecting_license(cookies): license_strings = { - 'MIT license': 'MIT ', - 'BSD license': 'Redistributions of source code must retain the ' + - 'above copyright notice, this', - 'ISC license': 'ISC License', - 'Apache Software License 2.0': - 'Licensed under the Apache License, Version 2.0', - 'GNU General Public License v3': 'GNU GENERAL PUBLIC LICENSE', + "MIT license": "MIT ", + "BSD license": "Redistributions of source code must retain the " + + "above copyright notice, this", + "ISC license": "ISC License", + "Apache Software License 2.0": "Licensed under the Apache License, Version 2.0", + "GNU General Public License v3": "GNU GENERAL PUBLIC LICENSE", } for license, target_string in license_strings.items(): with bake_in_temp_dir( - cookies, - extra_context={'open_source_license': license} + cookies, extra_context={"open_source_license": license} ) as result: - assert target_string in result.project.join('LICENSE').read() - assert license in result.project.join('setup.py').read() + assert target_string in result.project.join("LICENSE").read() + assert license in result.project.join("setup.py").read() def test_bake_not_open_source(cookies): with bake_in_temp_dir( - cookies, - extra_context={'open_source_license': 'Not open source'} + cookies, extra_context={"open_source_license": "Not open source"} ) as result: found_toplevel_files = [f.basename for f in result.project.listdir()] - assert 'setup.py' in found_toplevel_files - assert 'LICENSE' not in found_toplevel_files - assert 'License' not in result.project.join('README.rst').read() + assert "setup.py" in found_toplevel_files + assert "LICENSE" not in found_toplevel_files + assert "License" not in result.project.join("README.rst").read() diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug_report.md b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 668b9aa..0000000 --- a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug -assignees: '' - ---- - -**NetBox version** -What version of NetBox are you currently running? - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Additional context** -Add any other context about the problem here. diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug_report.yaml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..987254d --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,61 @@ +--- +name: 🐛 Bug Report +description: Report a reproducible bug in the current release of {{ cookiecutter.project_name }} +labels: ["type: bug"] +body: + - type: markdown + attributes: + value: > + **NOTE:** This form is only for reporting _reproducible bugs_ in a current {{ cookiecutter.project_name }} release. + - type: input + attributes: + label: {{ cookiecutter.project_name }} version + description: What version of {{ cookiecutter.project_name }} are you currently running? + placeholder: v0.1.0 + validations: + required: true + - type: input + attributes: + label: NetBox version + description: What version of NetBox are you currently running? + placeholder: v3.6.0 + validations: + required: true + - type: dropdown + attributes: + label: Python version + description: What version of Python are you currently running? + options: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + validations: + required: true + - type: textarea + attributes: + label: Steps to Reproduce + description: > + Please provide a minimal working example to demonstrate the bug. Begin with the + initialization of any necessary database objects and clearly enumerate each + operation carried out. Ensure that your example is as concise as possible + while adequately illustrating the issue. + + _Please refrain from including any confidential or sensitive + information in your example._ + validations: + required: true + - type: textarea + attributes: + label: Expected Behavior + description: What did you expect to happen? + placeholder: The script should execute without raising any errors or exceptions + validations: + required: true + - type: textarea + attributes: + label: Observed Behavior + description: What happened instead? + placeholder: A TypeError exception was raised + validations: + required: true diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/config.yml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3c3c026 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,12 @@ +# Reference: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser +blank_issues_enabled: false +contact_links: + - name: 📖 Contributing Policy + url: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/blob/main/CONTRIBUTING.md + about: "Please read through our contributing policy before opening an issue or pull request." + - name: ❓ Discussion + url: https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/discussions + about: "If you're just looking for help, try starting a discussion instead." + - name: 💬 Community Slack + url: https://netdev.chat + about: "Join #netbox on the NetDev Community Slack for assistance with installation issues and other problems." diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.md b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 11fc491..0000000 --- a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.yaml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..ab9f220 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,59 @@ +--- +name: ✨ Feature Request +description: Propose a new {{ cookiecutter.project_name }} feature or enhancement +labels: ["type: feature"] +body: + - type: markdown + attributes: + value: > + **NOTE:** This form is only for submitting well-formed proposals to extend or modify + {{ cookiecutter.project_name }} in some way. If you're trying to solve a problem but can't figure out how, or if + you still need time to work on the details of a proposed new feature, please start a + [discussion](https://github.com/netbox-community/pynetbox/discussions) instead. + - type: input + attributes: + label: {{ cookiecutter.project_name }} version + description: What version of {{ cookiecutter.project_name }} are you currently running? + placeholder: v0.1.0 + validations: + required: true + - type: input + attributes: + label: NetBox version + description: What version of NetBox are you currently running? + placeholder: v3.6.0 + validations: + required: true + - type: dropdown + attributes: + label: Feature type + options: + - Data model extension + - New functionality + - Change to existing functionality + validations: + required: true + - type: textarea + attributes: + label: Proposed functionality + description: > + Describe in detail the new feature or behavior you are proposing. Include any specific changes + to work flows, data models, and/or the user interface. The more detail you provide here, the + greater chance your proposal has of being discussed. Feature requests which don't include an + actionable implementation plan will be rejected. + validations: + required: true + - type: textarea + attributes: + label: Use case + description: > + Explain how adding this functionality would benefit {{ cookiecutter.project_name }} users. What need does it address? + validations: + required: true + - type: textarea + attributes: + label: External dependencies + description: > + List any new dependencies on external libraries or services that this new feature would + introduce. For example, does the proposal require the installation of a new Python package? + (Not all new features introduce new dependencies.) diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/housekeeping.yaml b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/housekeeping.yaml new file mode 100644 index 0000000..7778713 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/housekeeping.yaml @@ -0,0 +1,24 @@ +--- +name: 🏡 Housekeeping +description: A change pertaining to the codebase itself (developers only) +labels: ["type: housekeeping"] +body: + - type: markdown + attributes: + value: > + **NOTE:** This template is for use by maintainers only. Please do not submit + an issue using this template unless you have been specifically asked to do so. + - type: textarea + attributes: + label: Proposed Changes + description: > + Describe in detail the new feature or behavior you'd like to propose. + Include any specific changes to work flows, data models, or the user interface. + validations: + required: true + - type: textarea + attributes: + label: Justification + description: Please provide justification for the proposed change(s). + validations: + required: true diff --git a/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..16b7f20 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml @@ -0,0 +1,31 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore index 4c915d1..fa871cf 100644 --- a/{{cookiecutter.project_slug}}/.gitignore +++ b/{{cookiecutter.project_slug}}/.gitignore @@ -1,3 +1,129 @@ +# https://github.com/github/gitignore/blob/main/Global/macOS.gitignore + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# https://github.com/github/gitignore/blob/main/Python.gitignore + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -8,7 +134,6 @@ __pycache__/ # Distribution / packaging .Python -env/ build/ develop-eggs/ dist/ @@ -21,9 +146,11 @@ parts/ sdist/ var/ wheels/ +share/python-wheels/ *.egg-info/ .installed.cfg *.egg +MANIFEST # PyInstaller # Usually these files are written by a python script from a template @@ -38,14 +165,17 @@ 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/ +cover/ # Translations *.mo @@ -54,6 +184,8 @@ coverage.xml # Django stuff: *.log local_settings.py +db.sqlite3 +db.sqlite3-journal # Flask stuff: instance/ @@ -66,27 +198,61 @@ instance/ docs/_build/ # PyBuilder +.pybuilder/ target/ # Jupyter Notebook .ipynb_checkpoints +# IPython +profile_default/ +ipython_config.py + # pyenv -.python-version +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .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 + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml -# celery beat schedule file +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff celerybeat-schedule +celerybeat.pid # SageMath parsed files *.sage.py -# dotenv +# Environments .env - -# virtualenv .venv +env/ venv/ ENV/ +env.bak/ +venv.bak/ # Spyder project settings .spyderproject @@ -100,7 +266,14 @@ ENV/ # mypy .mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ -# IDE settings -.vscode/ -.idea/ +# Cython debug symbols +cython_debug/ diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml new file mode 100644 index 0000000..47d6177 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -0,0 +1,64 @@ +ci: + autoupdate_commit_msg: "chore: update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.9.1 + hooks: + - id: black + # It is recommended to specify the latest version of Python + # supported by your project here, or alternatively use + # pre-commit's default_language_version, see + # https://pre-commit.com/#top_level-default_language_version + language_version: python3.11 + + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + + - repo: https://github.com/pycqa/flake8 + rev: '6.1.0' + hooks: + - id: flake8 + additional_dependencies: [ + 'flake8-bugbear==23.9.16', + 'flake8-pyproject==1.2.3', + ] + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.9.0 + hooks: + - id: python-check-blanket-noqa + - id: python-check-blanket-type-ignore + - id: python-no-log-warn + - id: python-no-eval + - id: python-use-type-annotations + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + + - repo: https://github.com/mgedmin/check-manifest + rev: "0.47" + hooks: + - id: check-manifest + stages: [manual] + + - repo: https://github.com/PyCQA/bandit + rev: '1.7.5' + hooks: + - id: bandit diff --git a/{{cookiecutter.project_slug}}/.pypirc b/{{cookiecutter.project_slug}}/.pypirc new file mode 100644 index 0000000..52d2dd9 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.pypirc @@ -0,0 +1,10 @@ +[distutils] +index-servers = + pypi + testpypi + +[pypi] +repository = https://upload.pypi.org/legacy/ + +[testpypi] +repository = https://test.pypi.org/legacy/ diff --git a/{{cookiecutter.project_slug}}/CODE_OF_CONDUCT.md b/{{cookiecutter.project_slug}}/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..daa472b --- /dev/null +++ b/{{cookiecutter.project_slug}}/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders 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, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[{{ cookiecutter.email }}](mailto:{{ cookiecutter.email }}). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/{{cookiecutter.project_slug}}/CONTRIBUTING.md b/{{cookiecutter.project_slug}}/CONTRIBUTING.md index 2f596e2..ec3ee3c 100644 --- a/{{cookiecutter.project_slug}}/CONTRIBUTING.md +++ b/{{cookiecutter.project_slug}}/CONTRIBUTING.md @@ -3,7 +3,21 @@ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. -You can contribute in many ways: +We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features +- Becoming a maintainer + +## General Tips for Working on GitHub + +* Register for a free [GitHub account](https://github.com/signup) if you haven't already. +* You can use [GitHub Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) for formatting text and adding images. +* To help mitigate notification spam, please avoid "bumping" issues with no activity. (To vote an issue up or down, use a :thumbsup: or :thumbsdown: reaction.) +* Please avoid pinging members with `@` unless they've previously expressed interest or involvement with that particular issue. +* Familiarize yourself with [this list of discussion anti-patterns](https://github.com/bradfitz/issue-tracker-behaviors) and make every effort to avoid them. ## Types of Contributions diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index 24b2600..43967b6 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -1,30 +1,14 @@ -{% if cookiecutter.open_source_license == 'MIT license' -%} -MIT License +{% if cookiecutter.open_source_license == 'MIT' %} +The MIT License (MIT) +Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.full_name }} -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +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: -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: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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. -{% elif cookiecutter.open_source_license == 'BSD license' %} - -BSD License - -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} +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. +{%- elif cookiecutter.open_source_license == 'BSD' %} +Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.full_name }} All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -37,7 +21,7 @@ are permitted provided that the following conditions are met: list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -* Neither the name of the copyright holder nor the names of its +* Neither the name of {{ cookiecutter.project_name }} nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -51,61 +35,211 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -{% elif cookiecutter.open_source_license == 'ISC license' -%} -ISC License - -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} - -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} -Apache Software License 2.0 - -Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} - -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. -{% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%} -GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - {{ cookiecutter.project_short_description }} - Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.full_name }} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. -{% endif %} +{%- elif cookiecutter.open_source_license == 'GPLv3' %} +Copyright (c) {% now 'utc', '%Y' %}, {{ cookiecutter.full_name }} + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +{%- elif cookiecutter.open_source_license == 'Apache Software License 2.0' %} + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright {% now 'utc', '%Y' %} {{ cookiecutter.full_name }} + + 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. +{%- endif %} diff --git a/{{cookiecutter.project_slug}}/mkdocs.yml b/{{cookiecutter.project_slug}}/mkdocs.yml index 61198d2..5197a4e 100644 --- a/{{cookiecutter.project_slug}}/mkdocs.yml +++ b/{{cookiecutter.project_slug}}/mkdocs.yml @@ -20,9 +20,10 @@ theme: - navigation.instant - navigation.tabs.sticky markdown_extensions: + - attr_list - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg - pymdownx.critic - pymdownx.caret - pymdownx.mark diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml new file mode 100644 index 0000000..2071153 --- /dev/null +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -0,0 +1,106 @@ +# See PEP 518 for the spec of this file +# https://www.python.org/dev/peps/pep-0518/ + +[build-system] +requires = ["setuptools>=63.2.0", "wheel", "setuptools_scm[toml]>=8.0"] + +[project] +name = "{{ cookiecutter.project_slug }}" +authors = [ + {name = "{{ cookiecutter.full_name.replace('\"', '\\\"') }}", email = "{{ cookiecutter.email }}"}, +] +description = "{{ cookiecutter.project_short_description }}" +readme = "README.md" + +{%- set license_classifiers = { + 'MIT license': 'License :: OSI Approved :: MIT License', + 'BSD license': 'License :: OSI Approved :: BSD License', + 'ISC license': 'License :: OSI Approved :: ISC License (ISCL)', + 'Apache Software License 2.0': 'License :: OSI Approved :: Apache Software License', + 'GNU General Public License v3': 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)' +} %} + +classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', +{%- if cookiecutter.open_source_license in license_classifiers %} + '{{ license_classifiers[cookiecutter.open_source_license] }}', +{%- endif %} + 'Natural Language :: English', + "Programming Language :: Python :: 3 :: Only", + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', +] + +requires-python = ">=3.8.1" +dynamic = ["version"] + +[project.optional-dependencies] +test = [ + "bandit[toml]==1.7.5", + "black==23.3.0", + "check-manifest==0.49", + "flake8-bugbear==23.5.9", + "flake8", + "flake8-pyproject", + "pre-commit==3.3.1", + "pylint==2.17.4", + "pytest-mock<3.10.1", + "pytest-runner", + "pytest==7.3.1", + "pytest-github-actions-annotate-failures", + "shellcheck-py==0.9.0.2" +] + +[project.urls] +Documentation = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/blob/main/README.md" +Source = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" +Tracker = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues" + +[tool.bandit] +exclude_dirs = ["build","dist","tests","scripts","docs"] +number = 4 +recursive = true +targets = "{{ cookiecutter.project_slug }}" + +[tool.black] +line-length = 120 +target_version = ['py38', 'py39', 'py310', 'py311'] + +[tool.isort] +profile = "black" + +[tool.pylint] +max-line-length = 120 + +[tool.flake8] +max-line-length = 120 +exclude = [ + ".eggs", + ".venv", + ".tox", + ".mypy_cache", + ".pytest_cache", + ".vscode", + ".github", + ".git", + "dist", + "docs", + "tests", +] +ignore = [ + "E722", + "B001", + "W503", + "E203", + "D100", # These are all for ignoring missing docstring + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "F401" # unused import +] diff --git a/{{cookiecutter.project_slug}}/requirements_dev.txt b/{{cookiecutter.project_slug}}/requirements_dev.txt index 741ce49..f5e7766 100644 --- a/{{cookiecutter.project_slug}}/requirements_dev.txt +++ b/{{cookiecutter.project_slug}}/requirements_dev.txt @@ -1,9 +1,6 @@ -pip==22.3.1 -bump2version==0.5.11 -wheel==0.33.6 -watchdog==0.9.0 -flake8==6.0.0 -Sphinx==1.8.5 -twine==4.0.2 -black==22.12.0 -isort=5.11.4 +black==23.9.1 +bump2version==1.0.1 +flake8==6.1.0 +flit==3.9.0 +isort==5.12.0 +pip==22.2.1 diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg deleted file mode 100644 index 11b6b14..0000000 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ /dev/null @@ -1,46 +0,0 @@ -[flake8] -max-line-length = 120 -max-complexity = 18 -ignore = E203, E266, W503 -per-file-ignores = __init__.py:F401 -exclude = .git, - __pycache__, - setup.py, - build, - dist, - docs, - releases, - .venv, - .tox, - .mypy_cache, - .pytest_cache, - .vscode, - .github, - # By default test codes will be linted. - # tests - -[tox:tox] -isolated_build = true -envlist = py38, py39, py310, format, lint, build - -[gh-actions] -python = - 3.10: py310 - 3.9: py39 - 3.8: py38, format, lint, build - -[bumpversion] -current_version = {{ cookiecutter.version }} -commit = True -tag = True - -[bumpversion:file:setup.py] -search = version='{current_version}' -replace = version='{new_version}' - -[bumpversion:file:{{ cookiecutter.project_slug }}/__init__.py] -search = __version__ = '{current_version}' -replace = __version__ = '{new_version}' - -[bdist_wheel] -universal = 1 diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py deleted file mode 100644 index 60e0ed6..0000000 --- a/{{cookiecutter.project_slug}}/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python - -"""The setup script.""" - -from setuptools import setup, find_packages - -with open('README.md') as readme_file: - readme = readme_file.read() - -requirements = [] - -{%- set license_classifiers = { - 'MIT license': 'License :: OSI Approved :: MIT License', - 'BSD license': 'License :: OSI Approved :: BSD License', - 'ISC license': 'License :: OSI Approved :: ISC License (ISCL)', - 'Apache Software License 2.0': 'License :: OSI Approved :: Apache Software License', - 'GNU General Public License v3': 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)' -} %} - -setup( - author="{{ cookiecutter.full_name.replace('\"', '\\\"') }}", - author_email='{{ cookiecutter.email }}', - python_requires='>=3.8', - classifiers=[ - 'Development Status :: 2 - Pre-Alpha', - 'Intended Audience :: Developers', -{%- if cookiecutter.open_source_license in license_classifiers %} - '{{ license_classifiers[cookiecutter.open_source_license] }}', -{%- endif %} - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - ], - description="{{ cookiecutter.project_short_description }}", - install_requires=requirements, -{%- if cookiecutter.open_source_license in license_classifiers %} - license="{{ cookiecutter.open_source_license }}", -{%- endif %} - long_description=readme, - include_package_data=True, - keywords='{{ cookiecutter.project_slug }}', - name='{{ cookiecutter.project_slug }}', - packages=find_packages(include=['{{ cookiecutter.project_slug }}', '{{ cookiecutter.project_slug }}.*']), - test_suite='tests', - url='https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}', - version='{{ cookiecutter.version }}', - zip_safe=False, -) diff --git a/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py b/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py index 1bae6c4..ba6ee36 100644 --- a/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py +++ b/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py @@ -3,4 +3,3 @@ """Tests for `{{ cookiecutter.project_slug }}` package.""" from {{ cookiecutter.project_slug }} import {{ cookiecutter.project_slug }} - diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py index 17f7ab0..1bc3f66 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py @@ -1,19 +1,19 @@ """Top-level package for {{ cookiecutter.project_name }}.""" __author__ = """{{ cookiecutter.full_name }}""" -__email__ = '{{ cookiecutter.email }}' -__version__ = '{{ cookiecutter.version }}' +__email__ = "{{ cookiecutter.email }}" +__version__ = "{{ cookiecutter.version }}" from extras.plugins import PluginConfig class {{ cookiecutter.__model_name }}Config(PluginConfig): - name = '{{ cookiecutter.project_slug }}' - verbose_name = '{{ cookiecutter.project_name }}' - description = '{{ cookiecutter.project_short_description }}' - version = 'version' - base_url = '{{ cookiecutter.project_slug }}' + name = "{{ cookiecutter.project_slug }}" + verbose_name = "{{ cookiecutter.project_name }}" + description = "{{ cookiecutter.project_short_description }}" + version = "version" + base_url = "{{ cookiecutter.project_slug }}" config = {{ cookiecutter.__model_name }}Config diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/forms.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/forms.py index 62c5b20..f06a0e5 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/forms.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/forms.py @@ -1,13 +1,12 @@ from django import forms - from ipam.models import Prefix from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm from utilities.forms.fields import CommentField, DynamicModelChoiceField + from .models import {{ cookiecutter.__model_name }} class {{ cookiecutter.__model_name }}Form(NetBoxModelForm): - class Meta: model = {{ cookiecutter.__model_name }} - fields = ('name', 'tags') + fields = ("name", "tags") diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/models.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/models.py index 17419eb..d4af3fd 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/models.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/models.py @@ -1,19 +1,16 @@ from django.db import models from django.urls import reverse - from netbox.models import NetBoxModel class {{ cookiecutter.__model_name }}(NetBoxModel): - name = models.CharField( - max_length=100 - ) + name = models.CharField(max_length=100) class Meta: - ordering = ('name',) + ordering = ("name",) def __str__(self): return self.name def get_absolute_url(self): - return reverse('plugins:{{ cookiecutter.project_slug }}:{{ cookiecutter.__model_name|lower }}', args=[self.pk]) + return reverse("plugins:{{ cookiecutter.project_slug }}:{{ cookiecutter.__model_name|lower }}", args=[self.pk]) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/navigation.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/navigation.py index 24e8ff3..b506120 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/navigation.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/navigation.py @@ -1,20 +1,13 @@ from extras.plugins import PluginMenuButton, PluginMenuItem from utilities.choices import ButtonColorChoices - plugin_buttons = [ PluginMenuButton( - link='plugins:{{ cookiecutter.project_slug }}:{{ cookiecutter.__model_url_name }}_add', - title='Add', - icon_class='mdi mdi-plus-thick', - color=ButtonColorChoices.GREEN + link="plugins:{{ cookiecutter.project_slug }}:{{ cookiecutter.__model_url_name }}_add", + title="Add", + icon_class="mdi mdi-plus-thick", + color=ButtonColorChoices.GREEN, ) ] -menu_items = ( - PluginMenuItem( - link='plugins:{{ cookiecutter.project_slug }}:{{ cookiecutter.__model_url_name }}_list', - link_text='{{ cookiecutter.plugin_name }}', - buttons=plugin_buttons - ), -) +menu_items = (PluginMenuItem(link="plugins:{{ cookiecutter.project_slug }}:{{ cookiecutter.__model_url_name }}_list", link_text="{{ cookiecutter.plugin_name }}", buttons=plugin_buttons),) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/tables.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/tables.py index 2cac4ab..97cf02d 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/tables.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/tables.py @@ -1,15 +1,13 @@ import django_tables2 as tables - from netbox.tables import NetBoxTable, ChoiceFieldColumn + from .models import {{ cookiecutter.__model_name }} class {{ cookiecutter.__model_name }}Table(NetBoxTable): - name = tables.Column( - linkify=True - ) + name = tables.Column(linkify=True) class Meta(NetBoxTable.Meta): model = {{ cookiecutter.__model_name }} - fields = ('pk', 'id', 'name', 'actions') - default_columns = ('name', ) + fields = ("pk", "id", "name", "actions") + default_columns = ("name",) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/urls.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/urls.py index 5d722e9..59c5947 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/urls.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/urls.py @@ -1,18 +1,19 @@ from django.urls import path - from netbox.views.generic import ObjectChangeLogView + from . import models, views urlpatterns = ( - - path('{{ cookiecutter.__model_url }}s/', views.{{ cookiecutter.__model_name }}ListView.as_view(), name='{{ cookiecutter.__model_url_name }}_list'), - path('{{ cookiecutter.__model_url }}s/add/', views.{{ cookiecutter.__model_name }}EditView.as_view(), name='{{ cookiecutter.__model_url_name }}_add'), - path('{{ cookiecutter.__model_url }}s//', views.{{ cookiecutter.__model_name }}View.as_view(), name='{{ cookiecutter.__model_url_name }}'), - path('{{ cookiecutter.__model_url }}s//edit/', views.{{ cookiecutter.__model_name }}EditView.as_view(), name='{{ cookiecutter.__model_url_name }}_edit'), - path('{{ cookiecutter.__model_url }}s//delete/', views.{{ cookiecutter.__model_name }}DeleteView.as_view(), name='{{ cookiecutter.__model_url_name }}_delete'), - path('{{ cookiecutter.__model_url }}s//changelog/', ObjectChangeLogView.as_view(), name='{{ cookiecutter.__model_url_name }}_changelog', kwargs={ - 'model': models.{{ cookiecutter.__model_name }} - }), - + path("{{ cookiecutter.__model_url }}s/", views.{{ cookiecutter.__model_name }}ListView.as_view(), name="{{ cookiecutter.__model_url_name }}_list"), + path("{{ cookiecutter.__model_url }}s/add/", views.{{ cookiecutter.__model_name }}EditView.as_view(), name="{{ cookiecutter.__model_url_name }}_add"), + path("{{ cookiecutter.__model_url }}s//", views.{{ cookiecutter.__model_name }}View.as_view(), name="{{ cookiecutter.__model_url_name }}"), + path("{{ cookiecutter.__model_url }}s//edit/", views.{{ cookiecutter.__model_name }}EditView.as_view(), name="{{ cookiecutter.__model_url_name }}_edit"), + path("{{ cookiecutter.__model_url }}s//delete/", views.{{ cookiecutter.__model_name }}DeleteView.as_view(), name="{{ cookiecutter.__model_url_name }}_delete"), + path( + "{{ cookiecutter.__model_url }}s//changelog/", + ObjectChangeLogView.as_view(), + name="{{ cookiecutter.__model_url_name }}_changelog", + kwargs={"model": models.{{ cookiecutter.__model_name }}}, + ), ) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py index 09e543d..18f54f8 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/views.py @@ -20,5 +20,3 @@ class {{ cookiecutter.__model_name }}EditView(generic.ObjectEditView): class {{ cookiecutter.__model_name }}DeleteView(generic.ObjectDeleteView): queryset = models.{{ cookiecutter.__model_name }}.objects.all() - -