FindConfig
FindConfig is a Python package which implements the simple task of looking for a configuration file in a series of locations.
Usage
from findconfig import findconfig
config = findconfig("my.config.yaml")
The command above returns the Pathlib path of the first file found in the
locations indicated below (in the order), which has the given filename,
with or without a prepended dot (e.g. .my.config.yaml in the example above).
Config file locations
The locations which are searched are, in order of priority:
- the directories indicated in the XDG specification:
- XDG config home
- XDG config dirs
- the home directory of the user
- the source code directory of the calling program:
- the directory of the calling module
- any ancestor directory, stopping at (and including) the first one
which does not contain a
__init__.pyfile
- directories listed in the
more_pathkeyword argument
Options
The following keyword options can be used:
more_path (list of strings or Path, default: []): directory names to be searched
into, in the order, _after_ the default locations stated above
allow_dot (boolean, default: True): also look for the filename with a prepended
dot, if the filename does not start with a dot
use_xdg (boolean, default: True): enable searching in the XDG specification paths
use_home (boolean, default: True): enable searching in the user home directory
use_src (boolean, default: True): enable searching in the source code directory
of the program
src_climb (int, default: 1): maximum number of ancestor directories to search
from the first directory without a __init__.py file
starting from the directory containing the calling
module
exception (boolean, default: False): raise an exception is the file is not found
(default: return None and do not raise)
verbose (boolean, default: False): print the path of the found configuration
file to the standard error
Metadata
Release files for findconfig 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| findconfig-1.3.tar.gz | 6.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| findconfig-1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / findconfig-1.3.tar.gz
| Download URL | findconfig-1.3.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16d63530991022195a609dd7b33b6940ccc48be4677ff10883972df877bfe4fa
|
|
BLAKE2b-256 checksum How to use checksums |
cddccb96ffdab3d988136b116c37fbac6c254d0f0d01242deadeb59e9c6b9816
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / findconfig-1.3-py3-none-any.whl
| Download URL | findconfig-1.3-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9776ded6f1b8e115b707017393e2911a754edaa457238e7229f33dc9caeca89c
|
|
BLAKE2b-256 checksum How to use checksums |
b8ffbcfb271fb71ad142c8f43a748429045e8cb309b42de2e2b2833ff5926b6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|