Skip to main content

EduLinq Python Utilities

Common utilities used by EduLinq Python projects.

Installation / Requirements

This project requires Python >= 3.9.

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. The order that configuration sources are processed should be set by the tool using this library. A description of each configuration source (and the order they are loaded) is output in the help prompt from the --help flag.

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 provided by this library.

Source Description
CLI (Implicit) Loaded from the command line as a flag that is NOT --config.
CLI (Explicit) Loaded from the command line via the --config flag.
CLI File Loaded from one or more explicitly provided configuration files through the CLI.
Global Loaded from a file in a user-specific location, which is platform-dependent.
Local Loaded from a file in the current directory.
Project Loaded from a file in the current or nearest ancestor directory.

The system produces an error if a configuration file is unreadable (but not missing), or if a CLI-specified file is unreadable or missing.

CLI Configuration

CLI configurations are options specified directly on the command line, these are useful for quick option overrides without editing config files. Explicit configuration options are passed to the command line using 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. All other options specified on the command-line are considered "implicit" options.

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-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

Global Configuration

Global configurations 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 configurations are options that are specific to a directory. These options are generally used for special cases. Users should generally prefer project sources instead of local ones.

Project Configuration

Project configurations are options that are specific to a project or directory, like a project's build directory. Project configuration files are searched in multiple locations, starting with the current directory and moving up to each ancestor. The first file found is used. This source is very useful for setting project-specific options in your project's root.

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.

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-1.0.2.tar.gz (125.5 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-1.0.2-py3-none-any.whl (152.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for edq_utils-1.0.2.tar.gz
Algorithm Hash digest
SHA256 88f69a15a6cfb64d9b23a3652d3e73cc0252c3c0613b97ebd7bcef3b92b0086b
MD5 af3dd2a37328987f0d13fcdc425a2c9d
BLAKE2b-256 70259a6c0bdc013cd746839dbd15bb6b3807b09d488269f8d13cce57ad2bbd1d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for edq_utils-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0184e929571eb5f7775d7f430312925df14f1feb4ef8bd5f446072b4cdb661cd
MD5 b01bf7d5ff43fb0c1721a183c78b8273
BLAKE2b-256 ec333072f9fb5df87dba46d97f962430ba08391f3cd08e301e83a1293e5ee82b

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.3

2 files

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page