luckydonald / luckydonald-utils

A collection of utilities I use across different python projects
https://github.com/luckydonald/luckydonald-utils
Other
7 stars 0 forks source link

luckydonald-utils

A collection of utilities I use across different python projects.

Build Status PyPI

Documentation

Install

$ pip install luckydonald-utils Or, to install a specific version: $ pip install luckydonald-utils==0.84

Update

Via pip: $ pip install --upgrade luckydonald-utils

Using the package: $ python -m luckydonaldUtils.selfupdate

From python interpreter:

from luckydonaldUtils import selfupdate

Install from source

Update from source

luckydonaldUtils Documentation:

(not a complete list)

clazzes

Related to class manipulations.

djangos

Utilities for django.

files

Collection of things which are file related. (This structure exists since v0.47)

flasks

Utilities for flask. v0.59+

imports

Utilities for importing and import related stuff. v0.77+

jinja2

Utilities for the jinja templating engine. v0.64+

functions

Information about calling functions (Added in v0.35)

holder

(Added in v0.45)

Caches a result, and returns it. Useful in if statements.

In python it is not possible to store the result of an expression in a variable while being inside of an if:

if (temp=do_something()) == 42:
    foo(temp)

And storing it before is not an option? (you have a very resources-expensive call, or changing values, or are in an elif)

temp = do_something()
temp2 = do_something_else()
if temp == 42:
    foo(temp)
elif temp2:
    foo2(temp2)

Somebody need to hold that result for you:

from luckydonaldUtils.holder import Holder
h = Holder()
if h(do_something()) == 42:
    foo(h())
elif h(do_something_else()):
    foo2(h())

That's what Holder is for.

iterators

All stuff related to list and iterators.

interactions

Interact with the user.

network

regex

Package of some regular expressions I found useful.

tg_bots

Utilities for the telegram bots (pytgbot and/or teleflask).

text

String manipulation, etc.

typing

Additions to the great stuff in the typing module. Python 3+ it seems.

compat v0.58

Detecting versions and stuff. For string compatibility use .encoding.

webserver

(added in v0.20)


Notes

  1. regex.github.REPO_NAME_REGEX and regex.github.FILE_URL_REGEX where already present in v0.38 as regex.urls.github.REPO_NAME_REGEX and regex.urls.github.GITHUB_FILE_REGEX.
  2. exceptions.assert_type_or_raise was already present in v0.46 as exceptions.assert_or_raise.
  3. **