pesky-defaults
pesky-defaults is a small library for querying platform, distribution, and package defaults using a uniform interface.
The following default keys are made accessible and their values set according to the detected platform:
PREFIX
BIN_DIR
SBIN_DIR
LIB_DIR
LIBEXEC_DIR
SYSCONF_DIR
LOCALSTATE_DIR
RUN_DIR
DATA_DIR
A setuptools command is also provided (‘pesky_default’) so that project defaults can be specified, potentially overriding platform or distribution defaults.
Basic Usage
To use pesky-defaults, simply instantiate a new Defaults object and invoke the query methods ‘get’ or ‘getorelse’:
from pesky.defaults import Defaults
defaults = Defaults()
print defaults.get('PREFIX') # displays /usr on a linux platform
The Defaults class implements the collections.Mapping interface, so you can use the familiar mapping methods as well:
print defaults['LIB_DIR'] # displays /usr/lib on a linux platform
Project Defaults
If you specify a project name when instantiating the Defaults object, then all defaults from the project metadata will be loaded as well:
from pesky.defaults import Defaults
defaults = Defaults('my-project') # the project name as given to setuptools
This is all well and good, but how do the project defaults get set in the first place? This is where the ‘pesky_default’ setuptools command comes into play. By invoking the ‘pesky_default’ setuptools command, the .egg-info file called ‘pesky_defaults.json’ is manipulated. Once all project defaults are set as desired, the ‘install’ setuptools command can be invoked, which will perform the standard setuptools install routine and copy all egg-info files into place. For example:
$ cd my-project/ $ python ./setup.py pesky_default --command set --key foo --value bar $ python ./setup.py install
This snippet enters the source tree of the fictional project ‘my-project’, adds the project default ‘foo’, giving it the value ‘bar’, then installs the project (with the updated project defaults). The application code can then retrieve the ‘foo’ default:
from pesky.defaults import Defaults
defaults = Defaults('my-project') # the project name as given to setuptools
print defaults.get('foo') # displays bar
Metadata
Release files for pesky-defaults 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pesky-defaults-0.0.2.tar.gz | 5.6 kB | Without provenance | Details for pesky-defaults-0.0.2.tar.gz |
Release files / pesky-defaults-0.0.2.tar.gz
| Download URL | pesky-defaults-0.0.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a16f0b463cfbe8255db645280ca1fde41098740b1d5fecedb4302d3d564a5530
|
|
BLAKE2b-256 checksum How to use checksums |
2addde4b50f08f7c919a7770f096a654c00e4b1893a8cbc07481f9d1d4eabee4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pesky-defaults 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.