Skip to main content

My utility functions

Project description

argel1200.utilities

A small collection of utility functions that help reduce boilerplate code.

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


Download files

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

Source Distribution

argel1200-1.2.0rc2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

argel1200-1.2.0rc2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file argel1200-1.2.0rc2.tar.gz.

File metadata

  • Download URL: argel1200-1.2.0rc2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.3 Windows/11

File hashes

Hashes for argel1200-1.2.0rc2.tar.gz
Algorithm Hash digest
SHA256 6e639de7ac6715846f9cb8ea1e9a0083f2366e762d7f23285ec3a9d67cb17cef
MD5 dafe847f38a56207dbcd6ffeb9183894
BLAKE2b-256 a902d225ab515e9862fb5a78f43aa8d5358ff3b2525090d95b94a32e7dc30add

See more details on using hashes here.

File details

Details for the file argel1200-1.2.0rc2-py3-none-any.whl.

File metadata

  • Download URL: argel1200-1.2.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.3 Windows/11

File hashes

Hashes for argel1200-1.2.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 27511837f57d6338b1317fc5439e6e1d81fc4f09531687915346faaa0651b6ff
MD5 19d12a5c025dced2ad5875932d421f77
BLAKE2b-256 5b65caf6d51accf88cad1f8d22c1ec5d28cae021bdd777cfacbc557c3b6e0ed4

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