Skip to main content

Useful stuff for TCR projects!

Project description

TCRUtils - Utility Package for TCR Projects

TCRUtils is a collection of utility functions, classes, and helpers designed to streamline various tasks in TCR projects. Below is a brief overview of some of the key features.

Installation and Importing

Importing '''convention''' (it's just me using it...)

import tcrutils as tcr

Star-importng is supported (overriden) but you'd be a lot better off by just importng by name or the module itself not to litter your global scope with all this garbage

from tcrutils import timestr

Featured Features (yipee :3)

  • fmt_iterable(x: LITERALLY_ANY_OBJECT_TYPE): Pretty-formats any python object that i have thought of for easier readability, even some third-party-library ones.
  • console, or just tcr.c: Provides hikari-styled logging combined with the above fmt_iterable to pretty-print your debugging! Yay!
  • TStr: Convert between seconds and readable timestrs. Now with timezones! for example str("1h") -> int(3600).
  • ShelveDB: Quickly and easily set up a dict-based, python built-in shelve module's shelf - a python dictionary able to contain arbitrary python types that persists on restart.

Iterable Helpers

  • Or: Returns the first element of the tuple (arg, *args) that does not equal the supplied (none) variable, by default None. This is different from just doing x or y or y because it does not fail on falsey values, just the ones that are specified to be equal to the noney value
  • batched: py3.12 itertools.batched() in py3.11 with some extra features!
  • cut_at: Cut a string (or an iterable) with a specified suffix for example i'm running out of space on this markdown line so i will use th...
  • shuffled: Returns a shuffled version of an iterable. So you dont have to do random.shuffle(x) which does not return the shuffled

String and Formatting Utilities

  • commafy: Adds commas to numbers for better readability.
  • apostrophe_s: Handles the correct placement of apostrophes if the word ends with s for example "peoples'" and "mike's" (not "peoples's").

Error Handling

  • extract_error and extract_traceback: Extracts the error object's name and the error message (or the traceback's contents).

Decorators

  • @autorun: Automatically runs the the function whenever its definition is completed.
  • @timeit: Measures the execution time of a function and prints it to the screen.

Miscellaneous

  • insist: Prompts user input with a customizable insistence until a valid answer is provided, for example you can keep input()ing the user if they provided invalid value for an integer field.

This package includes many other useful utilities, go look for yourself if you want...

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

tcrutils-13.0.3.tar.gz (113.4 kB view details)

Uploaded Source

Built Distribution

tcrutils-13.0.3-py3-none-any.whl (129.1 kB view details)

Uploaded Python 3

File details

Details for the file tcrutils-13.0.3.tar.gz.

File metadata

  • Download URL: tcrutils-13.0.3.tar.gz
  • Upload date:
  • Size: 113.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.0 Windows/10

File hashes

Hashes for tcrutils-13.0.3.tar.gz
Algorithm Hash digest
SHA256 ec32e59fb31694ccb0f381363b4ac888a8ade71815af301a4f7d3ee727586a5c
MD5 3f2eab94a9f95f7af69e141d5fb8ee5d
BLAKE2b-256 6177c82d96a1f000c4a28700821c935c5204af42aa5284a4204a7432b5ddf9f2

See more details on using hashes here.

File details

Details for the file tcrutils-13.0.3-py3-none-any.whl.

File metadata

  • Download URL: tcrutils-13.0.3-py3-none-any.whl
  • Upload date:
  • Size: 129.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.0 Windows/10

File hashes

Hashes for tcrutils-13.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1f3dc1c814c0bb8b660b337b7aa6169fef98462e96f73fb7f54b1e37973005b8
MD5 13ab2797a2322d5c6381b2aac1251b5f
BLAKE2b-256 03c33d06c945553be66e3dc22f6244d67dc8062e16e3483cc2b75f69de9ca4cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page