My utility functions
Project description
argel1200.utilities
A small collection of utility functions that help reduce boilerplate code.
Version 1.3.0+ now spreads dependencies across files, so you can use e.g., open_file without having click and dumper installed.
Dumper Utilties
dumps
Wrapper for dumper, to make it eaier to get Perl style Data Dumper output. Assumes you want strings back, and leverages get_variable_name to pull the calling function.
get_variable_name
Helper function used by dumps. Perl's Data::Dumper gives variable_name=value output. This seeks to mimic that.
Class Utilties
import_class_from_string
Useful when you need to (or it's just more elegant to) dynamically determine the class based on a string that you are obtaining dynamically at runtime. Useful if you have a base class and multiple subclasses. Very useful if you want to build out your classes as needed (something can just be a base class now, then later on you could create a sub class for it and your script will start loading it as the new sub class automatically)
Logging Utilties
add_logging_level
Add custom logging levels
logging_init
Uses haggis.logs to add two additional "debug" logging levels: 'TRACE' and 'MEMDUMP' and initializes a logging instance if return_logger is True.
log_or_print
Streamlines if logger log.level else print workflows.
File Utilities
open_file
Wrapper for opening a file that provides basic error handling. Get those try blocks out of your script!
Command-line Utilties
process_cli_using_click
Useful if you want to use click in standalone=False mode. Provides basic error handling (required for standalone=False)
History
1.3.0
- Restructured so that people can use e.g. open_file without having to install click or dumper. -- Pulling some tricks in utilities/init.py to maintain backwards compatibility.
1.2.0
- Added my own add_log_level that supports Python 3.13. Used to use Haggis for this, but it's using old methods that no longer work.
- Improved open_file to check for permissions and tries to catch if a file is open on Windows
- Added log_or_print
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 argel1200-1.3.2.tar.gz.
File metadata
- Download URL: argel1200-1.3.2.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d1acf8c6f71beb6d1ff5b1454f1bdc6e6e772a1b06701fbaa6dd9b0b730949c
|
|
| MD5 |
aef16a02cae509aba7fb083eecf645f7
|
|
| BLAKE2b-256 |
014837c121fd279ff62c6f16b0da17b41aa89eb49c8536769ea778b3b2dd73df
|
File details
Details for the file argel1200-1.3.2-py3-none-any.whl.
File metadata
- Download URL: argel1200-1.3.2-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d6f6ad1a1eae2b59e4daa35857c7fd48892cab077b1088e934c1cf1f754a441
|
|
| MD5 |
50c27280ac8cb10df4c56801ddd13580
|
|
| BLAKE2b-256 |
1aa68d891b788404ed33cd3e278edff486ea80d2b96be01365edf826b5597808
|