Skip to content

Commit

Permalink
Merge pull request #12 from ByteOtter/add-application-settings
Browse files Browse the repository at this point in the history
Add parsing of settings parameters
  • Loading branch information
ByteOtter authored Jun 15, 2023
2 parents 61b2514 + b7c20eb commit 0db7752
Show file tree
Hide file tree
Showing 43 changed files with 1,379 additions and 38 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyright
pip install importlib-resources
pip install .[lint_requires,tests_require]
- name: Analysing the code with pyright
run: |
pyright $(git ls-files '*.py')
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Execute tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: pip install .[tests_require]

- name: Run tests
run: pytest -v --cov=src/ tests/
- name: Generate coverage report
run: coverage xml

# https://github.com/codacy/codacy-coverage-reporter-action
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
continue-on-error: true
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ __pycache__/
# C extensions
*.so

# IDEs
.idea/
.vscode/

# Documentation
changelog/*
!changelog/.gitkeep

# Distribution / packaging
.Python
build/
Expand Down
14 changes: 14 additions & 0 deletions .prospector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,22 @@ dodgy:
mccabe:
run: true

pycodestyle:
run: true
disable:
# https://github.com/psf/black/issues/354#issuecomment-397685631
- E203
- W503

pydocstyle:
run: true
disable:
# https://github.com/PyCQA/pydocstyle/issues/627
- D202
# https://github.com/PyCQA/pydocstyle/issues/141
- D203
# https://github.com/PyCQA/pydocstyle/issues/475
- D212

pyflakes:
run: true
Expand Down
1 change: 1 addition & 0 deletions changelog.d/7.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add parsing of application settings
3 changes: 3 additions & 0 deletions docs/_static/extend_width.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.wy-nav-content {
max-width: 90% !important;
}
21 changes: 21 additions & 0 deletions docs/code-autodoc/cobbler_tftp.exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cobbler\_tftp.exceptions package
================================

Submodules
----------

cobbler\_tftp.exceptions.settings\_exceptions module
----------------------------------------------------

.. automodule:: cobbler_tftp.exceptions.settings_exceptions
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: cobbler_tftp.exceptions
:members:
:undoc-members:
:show-inheritance:
15 changes: 7 additions & 8 deletions docs/code-autodoc/cobbler_tftp.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
cobbler\_tftp package
=====================

Submodules
----------
Subpackages
-----------

cobbler\_tftp.authentication module
-----------------------------------
.. toctree::
:maxdepth: 4

.. automodule:: cobbler_tftp.authentication
:members:
:undoc-members:
:show-inheritance:
cobbler_tftp.exceptions
cobbler_tftp.settings
cobbler_tftp.types

Module contents
---------------
Expand Down
10 changes: 10 additions & 0 deletions docs/code-autodoc/cobbler_tftp.settings.data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cobbler\_tftp.settings.data package
===================================

Module contents
---------------

.. automodule:: cobbler_tftp.settings.data
:members:
:undoc-members:
:show-inheritance:
21 changes: 21 additions & 0 deletions docs/code-autodoc/cobbler_tftp.settings.migrations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cobbler\_tftp.settings.migrations package
=========================================

Submodules
----------

cobbler\_tftp.settings.migrations.v1\_0 module
----------------------------------------------

.. automodule:: cobbler_tftp.settings.migrations.v1_0
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: cobbler_tftp.settings.migrations
:members:
:undoc-members:
:show-inheritance:
19 changes: 19 additions & 0 deletions docs/code-autodoc/cobbler_tftp.settings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cobbler\_tftp.settings package
==============================

Subpackages
-----------

.. toctree::
:maxdepth: 4

cobbler_tftp.settings.data
cobbler_tftp.settings.migrations

Module contents
---------------

.. automodule:: cobbler_tftp.settings
:members:
:undoc-members:
:show-inheritance:
10 changes: 10 additions & 0 deletions docs/code-autodoc/cobbler_tftp.types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cobbler\_tftp.types package
===========================

Module contents
---------------

.. automodule:: cobbler_tftp.types
:members:
:undoc-members:
:show-inheritance:
7 changes: 0 additions & 7 deletions docs/code-autodoc/main.rst

This file was deleted.

6 changes: 2 additions & 4 deletions docs/code-autodoc/modules.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
src
===
cobbler_tftp
============

.. toctree::
:maxdepth: 4

cobbler_tftp
main
service
7 changes: 0 additions & 7 deletions docs/code-autodoc/service.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
html_css_files = ["extend_width.css"]
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Welcome to Cobbler-TFTP's documentation!
:maxdepth: 2
:caption: Contents:

Code Documentation<code-autodoc/modules.rst>



Indices and tables
Expand Down
16 changes: 12 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ package_dir=
packages = find:
include_package_data = True
setup_requires =
setuptools>=44.11.0
setuptools-scm~=7.1.0
wheel>=0.37.1
setuptools
setuptools-scm
wheel
install_requires =
fbtftp>=0.5
python-daemon>=3.0.1
python-daemon>=3.0.1; python_version>"3.6"
python-daemon==2.3.2; python_version=="3.6"
pyyaml>=6.0
click>=8.0.4; python_version>"3.6"
click==8.0.4; python_version=="3.6"
importlib-resources==5.4.0; python_version=="3.6"
schema>=0.6.7; python_version>"3.6"
schema==0.6.7; python_version=="3.6"

[options.extras_require]
tests_require =
pytest>=7.0.1
pytest-mock>=3.6.1
pytest-cov>=4.1.0; python_version>"3.6"
pytest-cov==3.0.0; python_version=="3.6"
lint_requires =
pre-commit>=2.0.1
black>=22.1.0
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
This file only serves to allow compatibility with legacy build tools
"""
"""File only serves to allow compatibility with legacy build tools."""

from setuptools import setup

Expand Down
5 changes: 1 addition & 4 deletions src/cobbler_tftp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
"""
Cobbler-TFTP provides a stateless TFTP-Server to provide an alternative method of operations
for cobbler-sync.
"""
"""Cobbler-TFTP provides a stateless TFTP-Server as an alternative method of operations for ``cobbler sync``."""
9 changes: 9 additions & 0 deletions src/cobbler_tftp/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Custom exceptions for cobbler-tftp."""


class CobblerTftpException(Exception):
"""Generic cobbler-tftp exception."""

def __init__(self, message: str = "CobblerTFTPException"):
"""Create custom generic CobblerTFTPException."""
super().__init__(message)
25 changes: 25 additions & 0 deletions src/cobbler_tftp/exceptions/settings_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Custom exceptions for cobbler-tftp's settings module."""


class CobblerTftpSettingsException(Exception):
"""Generic cobbler-tftp exception."""

def __init__(self, message: str = "An Error occured!"):
"""Create custom generic settings exception."""
super().__init__(message)


class CobblerTftpMissingConfigParameterException(KeyError):
"""Exception to handle a missing but required config parameter."""

def __init__(
self,
message="MissingConfigParameterException: Application settings missing required parameter!",
parameter: str = "NONE",
):
"""Create custom exception to raise when a specific config parameter is missing for the application settings."""
if parameter is None or parameter == "NONE":
raise ValueError("Parameter cannot be 'NONE'")
self.parameter = parameter
self.message = str.join(message, parameter)
super().__init__(message, parameter)
Loading

0 comments on commit 0db7752

Please sign in to comment.