An utility library for python
Project description
Flashback
You've probably already implemented it.
Flashback is a collection of python utilities: it contains classes, metaclasses, decorators, functions, constants, etc. that you might have written a couple times already.
Installing
Flashback supports python 3.6+.
Pip:
pip install flashback
Build from sources:
git clone git@github.com:PaulRenvoise/flashback.git
cd flashback
python setup.py install
Contents
Flashback's helpers are currently organised within 7 modules, and global helpers:
accessing/dig()recursively fetch keys in a nested dict
caching/Cachesupports several cache stores: in-memory, disk, Redis, and Memcached@cachedcaches a callable's return value based on its arguments
debugging/xp()prints debug information about its given arguments@profiledcollects and dumps profiling stats over a callable's executioncaller()allows a developer to print debug information about a callable's callerget_callable()extracts a callable instance from a frameget_call_context()finds and returning the code context around a call made in a frameget_frameinfo()implements a fasterinspect.stack()[x]
formatting/oxford_join()joins strings in a human-readable waytransliterate()represents unicode text in ASCII (using Unidecode)camelize()transforms any case to camelCasepascalize()transforms any case to PascalCasesnakeize()transforms any case to snake_casekebabize()transforms any case to kebab-caseparameterize()formats a given string to be used in URLsordinalize()represents numbers in their ordinal representationsadverbize()represents numbers in their numeral adverb representationstruncate()truncates long sentences at a given limit and append a suffix if neededsingularize()returns the singular form of a given wordpluralize()returns the plural form of a given word
iterating/renumerate()enumerates an iterable starting from its endchunks()splits an iterable into smaller chunks, padding them if requestedpartition()splits an iterable into items validating a predicate and the ones that don'tuniq()removes duplicates from an iterable while keeping the items' ordercompact()removes None values from an iterableflatten()unpacks nested iterable into the given iterableflat_map()applies a function to every item and nested item of the given iterable
i16g/Localedynamically loads localization files from a package path
importing/import_class_from_path()fetches a class from a package path and returns itimport_module_from_path()exposes the contents of a module as globals from a package path
logging/DEFAULT_CONSOLE_CONFIGURATIONlogs to stderr with a sensible set of informationDJANGO_CONSOLE_CONFIGURATIONlogs to stderr with the same formatting as Django's loggerFLASK_CONSOLE_CONFIGURATIONlogs to stderr with the same formatting as Flask's loggerPYRAMID_CONSOLE_CONFIGURATIONlogs to stderr with the same formatting as Pyramid's loggerRAILS_CONSOLE_CONFIGURATIONlogs to stderr with the same formatting as RoR's loggerAffixedStreamHandlerallows custom affixes to log records@mutedsilences all (or selected) loggers during a callable's execution
Borgexposes a class useful to produce a singleton behaviour across multiple instancesSentinelexposes a class that can be used to implement the Sentinel design patternSingletonexposes a metaclass useful to implement the Singleton design pattern@classpropertycombines @classmethod and @property (with support for @attr.setter)@deprecateddocuments deprecated callables with a explicit message@retryableretries failing executing of a callable@sampledimplements sampling strategies to filter calls made to a callable@timedmeasures and prints the execution time of a callable@timeoutablestops the execution of a callable if its run time is too long
Contributing
The Pull Request template has a checklist containing everything you need to submit a new PR.
Run the tests with pytest:
pytest tests
Run the lint with pylint:
pylint flashback/ tests/
License
Flashback is released under the MIT License.
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 flashback-1.2.0.tar.gz.
File metadata
- Download URL: flashback-1.2.0.tar.gz
- Upload date:
- Size: 43.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
740b43f7ba4c3041b78efc8e36414e1677d224807f3ae3d294fba12b7d7dd5a9
|
|
| MD5 |
9955dbee9bec393980c4201832817906
|
|
| BLAKE2b-256 |
f9cb7395270fe2db1fb6fed98d2d20245de916f72a4d1305c96460bfb523f1f5
|
File details
Details for the file flashback-1.2.0-py3-none-any.whl.
File metadata
- Download URL: flashback-1.2.0-py3-none-any.whl
- Upload date:
- Size: 61.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cfbe5d5b13832893389bb46dc69f49d4d637d54e02e3a4655cf8c71fa3807e7
|
|
| MD5 |
3e019ec59f3d06c3f0c6439756e83587
|
|
| BLAKE2b-256 |
cbfa49a043f0db8d2514dfd2c06d4acff18241a067f8761d96664f73f4d94f04
|