Skip to main content

Easy functions for paths, logging and configuration files

Project description

polite-config actions codecov PyPI - Python Version

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polite_config-3.0.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polite_config-3.0.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

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

Hashes for polite_config-3.0.0.tar.gz
Algorithm Hash digest
SHA256 eb02d124aea9e5fc9334f4c7856ef8a7430482ad4a51222424dea32a813606c3
MD5 460b70dee462a65c2ac3038b474edd64
BLAKE2b-256 c4d899b10db4fcc8cb7e650e2cbf06c42adeba3489836f63ba2895ddb5d2544f

See more details on using hashes here.

Provenance

The following attestation bundles were made for polite_config-3.0.0.tar.gz:

Publisher: release.yml on DTOcean/dtocean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for polite_config-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86ca323bb4a263346e8e045bd61aacb7ec8f9e14dac8e8795f14313ecd502bd9
MD5 13b1183400ca48ad693c00a12745aaba
BLAKE2b-256 2ae8dd0470d01074a7784b87dd586e955d55749353caa6f574deb96833aedf6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for polite_config-3.0.0-py3-none-any.whl:

Publisher: release.yml on DTOcean/dtocean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page