Skip to main content

Easy functions for paths, logging and configuration files

Reason this release was yanked:

Yanked stub version

Project description

polite-config

Easy functions for paths, logging and configuration files.

Installation

Installation and development of polite-config uses 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

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.add_named_logger("polite")
>>> logger.info("Hello World")
INFO - polite - Hello World

Note that classes such as ModPath and UserDataPath are subclasses of pathlib.Path.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

See this blog post for information regarding development of the DTOcean ecosystem.

Please make sure to update tests as appropriate.

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-1.0.0.tar.gz (13.0 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-1.0.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polite_config-1.0.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Windows/10

File hashes

Hashes for polite_config-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0f8df1fc1bc94404a8c318b9fc3843e5655b2aa862db1f1f776a7c4fddd68a6a
MD5 cccf8a87ab02720929608b43a5961a37
BLAKE2b-256 c9f5f03a7b00eccbc3670701ad6d04ef7a203a85676943e999941832e5bade3c

See more details on using hashes here.

File details

Details for the file polite_config-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: polite_config-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Windows/10

File hashes

Hashes for polite_config-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cfedbd7b2b615d72f59aa57e7fa1f7e89499fe25d784c71ad5756edc34950ba
MD5 1a1c20f8d3aabfde2201d1173a60bd52
BLAKE2b-256 7c40194cd35609725376f14aa61654b30ec8dad926c4787cb955618ae191cea9

See more details on using hashes here.

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