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.1.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.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file polite_config-3.0.1.tar.gz.

File metadata

  • Download URL: polite_config-3.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 98df6b8bdace8fe900660db3e20fed68af0e1b23a8ffd81bb2142e548aedea94
MD5 618ea861723a357ff376a35f6645da4a
BLAKE2b-256 b1cf7b6bc5289568c393c152565b7a6ea17c55345b58a27cfca3da497ef8c7d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for polite_config-3.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: polite_config-3.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c7cdac3de5e45e389087820aae57da95fc7cf2aefff66a0eaf38951d2f5c60e
MD5 bcf8f968f887f34b6e8f1b4f7ca4f364
BLAKE2b-256 56e95fc365c54115cf030501fb5268061c6ec0fc665bce39ac0938b194b7d612

See more details on using hashes here.

Provenance

The following attestation bundles were made for polite_config-3.0.1-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