EpicStuff
A few somewhat useful (Epic) python objects/functions (Stuff).
Installation
pip install epicstuff
Dict
Lets you access a dictionary's keys as attributes
JDict version
Points to a target instead of converting it into a (new) Dict object. Useful for when your "target" is say, a CommentedMap and you don't want to loose the comments.
- Example:
from epicstuff import Dict
d = Dict({})
d.x = 1
BoxDict version
Simpler (less features) than Box but with more features (recursive conversion and creation on access) than jdict (and without some of the "extra" stuff)
- Example:
from epicstuff import Dict
d = Dict({"a": 1, "b": {"c": 2, "d": 3}}, _convert=None)
print(d.b.c) # 2
NewDict version
Combines the source-class preservation of JDict (eg. wrapped CommentedMaps keep their comments) and being a dict subclass, so isinstance(d, dict) is True. Also has extra features of BoxDict like auto-creation.
- Example:
from epicstuff import NewDict
d = NewDict({"a": 1, "b": {"c": 2, "d": 3}}, _convert=None)
print(d.b.c) # 2
How it works: dict sources are turned into NewDict. Other mappings has its __class__ swapped in place to a generated dotSourceName (e.g. dotCommentedMap) that inherits from both NewDict and the source class. The instance keeps its original data and NewDict features.
Rich Trace
Easily install terminal-wide rich.traceback and use helpers to ensure pretty tracebacks with async functions.
- Example:
from epicstuff import run_install_trace
- or:
from epicstuff import rich_trace
@rich_trace
async def some_func():
raise Exception
some_func()
- or:
@rich_trace(_return=0)
async def some_func():
raise Exception
some_func()
- or:
with rich_trace():
raise Exception
Bar
Makes using nested progress bars from rich.progress easier
- Example:
basically lets you replace
from rich.progress import Progress
with Progress() as progress:
task = progress.add_task("task", total=100)
for i in range(100):
sub_task = progress.add_task("subtask", total=100)
for j in range(100):
time.sleep(0.01) # some task
progress.update(sub_task, advance=1)
progress.remove_task(sub_task)
progress.update(task, advance=1)
with
from epicstuff import Bar
with Bar() as bar:
for i in bar(range(100)):
for j in bar(range(100), transient=True):
time.sleep(0.01) # some task
with minor extra features (fancier default bar)
Timer
a simple timer to time execution of code a code segment
- Example:
from epicstuff import timer
with timer():
pass # some code
# outputs: Time elapsed: 0.0 seconds
# message can be changed by passing a string with {} to timer
s
An autoformatting string. Removes extra indent and leading/trailing newlines.
- Example:
from epicstuff import s
string = s('''
line 1
line 2
line 3
''') + 'line 4'
print(s)
# line 1
# line 2
# line 3
# line 4
Permissify
make function ignore extra arguments instead of raising an error.
- Example:
from epicstuff import perm
def tmp(a, b=2): ...
perm(tmp)(1, 2, b=3, c=5) # this will run without raising TypeError
fix_import
Lets you do relative imports and absolute imports from parent folder without having to run the file as a module.
- Example:
from epicstuff import run_fix_import
- or
from epicstuff import fix_import
fix_import('src')
# or
fix_import('..')
from src.stuff import *
# or
from ..stuff import *
Stuff
extra functions:
open: overwritesopenwithPath.openandencoding='utf8'with open('file') as f: ...
wrap: just a renamedfunctools.partialrmap:mapbut recursive for lists and dicts- takes
listordictand 2 functions, will apply function 1 to all keys and function 2 to all values
- takes
Tee: Text stream that writes to multiple underlying streams. (Example: redirect stdout to terminal and a file)Pointer: an object you can kinda use like a pointer. (Examplenumber = Pointer(5), number._t = 6)
TODO:
- when doing bar in bar with the second bar being transient, make so that the dots continue from where the previous bar left off
- implement auto transient for bar in bar
- add and implement simple=False for .Bar.track()
- look into using
wrapt.ObjectProxy
Stuff:
- Note to self:
- "self install" using
pip install -U -e . - upload by running
python -m buildthentwine upload --skip-existing dist/*
- "self install" using
Metadata
Release files for epicstuff 3.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| epicstuff-3.0.9.tar.gz | 40.1 kB | Without provenance | Details for epicstuff-3.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| epicstuff-3.0.9-py3-none-any.whl | Python 3 | none | any | Details for epicstuff-3.0.9-py3-none-any.whl |
Total release size: 82.0 kB
Release files / epicstuff-3.0.9.tar.gz
| Download URL | epicstuff-3.0.9.tar.gz |
|---|---|
| Size | 40.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1fe5047e4837f0b9b2e95d89f57b4cd45f537448e3245d113a7f1ca0690740a
|
|
BLAKE2b-256 checksum How to use checksums |
39e53832435c69d224777aa35cfcc116a56af806d784639e6fba053be4335e5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / epicstuff-3.0.9-py3-none-any.whl
| Download URL | epicstuff-3.0.9-py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7575fced06e0b8fda8eeb302bf4ac653e85ccd295d82555fa79234000897568
|
|
BLAKE2b-256 checksum How to use checksums |
dad2b0f950f72fe942c12a1345b522db10556f1a8fda59099888c98a42cc8030
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for epicstuff 3.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.