Common utilities used by EduLinq Python projects.
Project description
EduLinq Python Utilities
Common utilities used by EduLinq Python projects.
Installation / Requirements
This project requires Python >= 3.8.
The project can be installed from PyPi with:
pip3 install edq-utils
Standard Python requirements are listed in pyproject.toml.
The project and Python dependencies can be installed from source with:
pip3 install .
Configuration System
This project provides a configuration system that supplies options (e.g., username, password) to a command-line interface (CLI) tool. The configuration system follows a tiered order, allowing options to be specified and overridden from both files and command-line options.
Configuration Sources
In addition to CLI options, the configuration system loads options from JSON files located across multiple directories.
By default, configuration files are named edq-config.json.
This value is customizable, but this document will assume the default is used.
For example, a configuration file containing the user and pass options might look like this:
{
"user": "alice",
"pass": "password123"
}
The table below summarizes the configuration sources in the order they are evaluated. Values from earlier sources can be overwritten by values from later sources.
| Source | Description |
|---|---|
| Global | Loaded from a file in a user-specific location, which is platform-dependent. |
| Local | Loaded from a file in the current or nearest ancestor directory. |
| CLI File | Loaded from one or more explicitly provided configuration files through the CLI. |
| CLI | Loaded from the command line. |
The system produces an error if a global or local configuration file is unreadable (but not missing), or if a CLI-specified file is unreadable or missing.
Global Configuration
Global configuration are options that are user specific and stick with the user between projects, these are well suited for options like login credentials.
The global configuration file defaults to <platform-specific user configuration location>/edq-config.json.
The configuration location is chosen according to the XDG standard (implemented by platformdirs).
Below are examples of user-specific configuration file paths for different operating systems:
- Linux --
/home/<user>/.config/edq-config.json - Mac --
/Users/<user>/Library/Application Support/edq-config.json - Windows --
C:\Users\<user>\AppData\Local\edq-config.json
The default global configuration location can be changed by passing a path to --config-global through the command line.
Below is an example command for specifying a global configuration path from the CLI:
python3 -m edq.cli.config.list --config-global ~/.config/custom-config.json
Local Configuration
Local configuration are options that are specific to a project or directory, like a project's build directory. Local configuration files are searched in multiple locations, the first file found is used. The local config search order is:
edq-config.jsonin the current directory.- A legacy file in the current directory (only if a legacy file is preconfigured).
edq-config.jsonin any ancestor directory on the path to root (including root itself).
CLI-Specified Config Files
CLI config files are options specified on the command line via a file.
These are useful for a common set of options you don’t need every time, such as login credentials for different user.
Any files passed via --config-file will be loaded in the order they appear on the command line.
Options from later files override options from previous files.
Below is an example of a CLI specified configuration paths:
python3 -m edq.cli.config.list --config-file ./edq-config.json --config-file ~/.secrets/edq-config.json
CLI Configuration
CLI configurations are options specified directly on the command line, these are useful for quick option overrides without editing config files.
Configuration options are passed to the command line by the --config flag in this format <key>=<value>.
The provided values overrides the values from configuration files.
Configuration options are structured as key value pairs and keys cannot contain the "=" character.
Below is an example of specifying a configuration option directly from the CLI:
python3 -m edq.cli.config.list --config user=alice --config pass=password123
CLI Config Options
The table below lists common configuration CLI options available for CLI tools using this library.
| CLI Option | Description |
|---|---|
--config-global |
Override the global config file location. |
--config-file |
Load configuration options from a CLI specified file. |
--config |
Provide additional options to a CLI command. |
--help |
Display standard help text and the default global configuration file path for the current platform. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file edq_utils-0.1.0.tar.gz.
File metadata
- Download URL: edq_utils-0.1.0.tar.gz
- Upload date:
- Size: 66.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61d2206f4e4fe93a5d1dcc8172bba8e3b41cd1bcc49b08010fc61c8082125135
|
|
| MD5 |
1712d290cdb98240fbabb25e91792e45
|
|
| BLAKE2b-256 |
6ed0a81b53dbffae77e52b70864782ecbef7c0e5f83c158bba1c20269878c2ff
|
File details
Details for the file edq_utils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: edq_utils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 74.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c6b6afef4712d30a783ef7fa103dbf44c2d7b99e93b637a11f9589d4ea779a7
|
|
| MD5 |
cb1deb8edda69e0748140278f054b132
|
|
| BLAKE2b-256 |
65caab3af956d0cd3ed5c1cb699012b05b5feb23a39b940203a1eb62e37ecb46
|