Easy functions for paths, logging and configuration files
Project description
polite-config
Easy functions for paths, logging and configuration files.
Part of the DTOcean suite of tools.
Installation
pip install polite-config
Usage
An example of setting up logging using a user-specific yaml configuration file.
Copy the default logging file from the module source code to the user's data
directory (C:\Users\<USERNAME>\AppData\Roaming\DTOcean\polite):
>>> from polite_config.paths import (DirectoryMap, ModPath, UserDataPath)
>>> objdir = ModPath("polite", "config")
>>> datadir = UserDataPath("polite", "DTOcean")
>>> dirmap = DirectoryMap(datadir, objdir)
>>> dirmap.copy_file("logging.yaml", overwrite=True)
>>> datadir.isfile("logging.yaml")
True
Use the copied configuration file to set up logging:
>>> from polite_config.configuration import Logger
>>> log = Logger(datadir)
>>> log_config_dict = log.read()
>>> log.configure_logger(log_config_dict)
>>> logger = log.get_named_logger("polite")
>>> logger.info("Hello World")
INFO - polite - Hello World
Note that classes such as ModPath and UserDataPath are subclasses of
pathlib.Path.
Development
polite-config is developed using the Poetry dependency manager. Poetry must be installed and available on the command line.
To install:
poetry install
Tests
A test suite is provided with the source code that uses pytest.
Install the testing dependencies:
poetry install --with test
Run the tests:
poetry run pytest
Code quality can also be audited using the ruff and pyright tools.
Install the dependencies:
poetry install --with audit
Run the audit:
poetry run ruff
poetry run pyright src
The above tests can be run across all compatible Python versions using tox and tox-uv. To install and run:
poetry install --with tox
poetry run tox
Contributing
Please see the dtocean GitHub repository for contributing guidelines.
Credits
This package was initially created as part of the EU DTOcean project by Mathew Topper at TECNALIA.
It is now maintained by Mathew Topper at Data Only Greater.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polite_config-3.0.0.tar.gz.
File metadata
- Download URL: polite_config-3.0.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb02d124aea9e5fc9334f4c7856ef8a7430482ad4a51222424dea32a813606c3
|
|
| MD5 |
460b70dee462a65c2ac3038b474edd64
|
|
| BLAKE2b-256 |
c4d899b10db4fcc8cb7e650e2cbf06c42adeba3489836f63ba2895ddb5d2544f
|
Provenance
The following attestation bundles were made for polite_config-3.0.0.tar.gz:
Publisher:
release.yml on DTOcean/dtocean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polite_config-3.0.0.tar.gz -
Subject digest:
eb02d124aea9e5fc9334f4c7856ef8a7430482ad4a51222424dea32a813606c3 - Sigstore transparency entry: 1076408087
- Sigstore integration time:
-
Permalink:
DTOcean/dtocean@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DTOcean
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Trigger Event:
push
-
Statement type:
File details
Details for the file polite_config-3.0.0-py3-none-any.whl.
File metadata
- Download URL: polite_config-3.0.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86ca323bb4a263346e8e045bd61aacb7ec8f9e14dac8e8795f14313ecd502bd9
|
|
| MD5 |
13b1183400ca48ad693c00a12745aaba
|
|
| BLAKE2b-256 |
2ae8dd0470d01074a7784b87dd586e955d55749353caa6f574deb96833aedf6f
|
Provenance
The following attestation bundles were made for polite_config-3.0.0-py3-none-any.whl:
Publisher:
release.yml on DTOcean/dtocean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polite_config-3.0.0-py3-none-any.whl -
Subject digest:
86ca323bb4a263346e8e045bd61aacb7ec8f9e14dac8e8795f14313ecd502bd9 - Sigstore transparency entry: 1076408137
- Sigstore integration time:
-
Permalink:
DTOcean/dtocean@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DTOcean
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27c94b2b57f33f0668cbb02208a94ce3c1d87543 -
Trigger Event:
push
-
Statement type: