Skip to main content

Common utilities used by EduLinq Python projects.

Project description

EduLinq Python Utilities

Common utilities used by EduLinq Python projects.

Links:

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:

  1. edq-config.json in the current directory.
  2. A legacy file in the current directory (only if a legacy file is preconfigured).
  3. edq-config.json in 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edq_utils-0.1.8.tar.gz (81.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edq_utils-0.1.8-py3-none-any.whl (77.7 kB view details)

Uploaded Python 3

File details

Details for the file edq_utils-0.1.8.tar.gz.

File metadata

  • Download URL: edq_utils-0.1.8.tar.gz
  • Upload date:
  • Size: 81.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for edq_utils-0.1.8.tar.gz
Algorithm Hash digest
SHA256 f390164310ed6da7e25e9eb6122d263a51ebaf51e272498bc66a46bafbbd6917
MD5 6516200e15bb4383fc126e13fbbc78e1
BLAKE2b-256 41358eef7f52a5a74d2e9dc2c8d39180722558c4cbfe1faecb5f03b7eedc2193

See more details on using hashes here.

File details

Details for the file edq_utils-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: edq_utils-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 77.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for edq_utils-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4bfefab4b49c07d2b5876fe9c186a17be7652ab86b13a7534e451079a2ad093b
MD5 f011184e4f7b2b7886f28dc967b67c91
BLAKE2b-256 c83a5985d7b35684c643dad510de40f013a0b4e1474713e5a758f06681efb537

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