Python3 commons for the Drizm organization
Project description
Python Commons
This package includes shared code used by the Drizm organizations development team.
It is not intended for public usage but you may still download, redistribute or modify it to your liking.
Usage
Basic Install (utils only):
pip install drizm-commons
Full install (SQLAlchemy features available):
pip install drizm-commons[sqla]
Import like so:
import drizm_commons
Documentation
Utilities
Convinience Functions:
from drizm_commons.utils import *
# Check whether function name is dunder
is_dunder("__name__") # True
# Check if a given string is a valid UUIDv4
uuid4_is_valid("myvalue") # False
# Check if a URL is valid and the contents URL-Safe
url_is_http("https://myapp.com/") # True
# Get the current applications root path
Path(get_application_root())
Path with extra features:
from drizm_commons.utils import Path
# Recursively delete a folder
path = Path(__file__).parent
path.rmdir(recursive=True)
Cache last passed parameter:
from drizm_commons.utils import memoize
@memoize
def foo(a):
return a
foo(3) # 3
foo() # 3
Introspection
from drizm_commons.inspect import SQLAIntrospector
table = SQLAIntrospector(my_table_instance)
""" Attributes """
table.tablename # get the name of the table
table.classname # get the classname of the declarative instance
table.columns # get all SQLA fields of the class
table.column_attrs # get all SQLA fields + property and hybrid_property of the class
Changelog
0.1.1
- Added SQLAlchemy JSON Encoder
- Fixed bugs related to the Introspection API
- Added table registry
- Added additional utilities
0.1.2
- Added get_root_path and recursive delete Path utilities
- Fixed various bugs
0.2.0
- Added full test suite
- Added testing tools
- Revamped introspection API
- Provided additional overrides for the SQL connection adapter
0.2.1
- Added support for datetime JSON encoding
0.2.2
- Improved in-code documentation
- Integrated additional utils from drizm-django-commons
0.3.0
- Added introspection capabilities for property and SQLAlchemy's hybrid_property
- SQLAEncoder now respects property and hybrid_property on SQLA declarative instances
- Additional customizability hooks for custom fields or data handling
- Support for JSON-Encoding table instances
- Added SQLA as optional dependency
- Added additional testing utilities
0.3.1
- Improved code documentation
- Added docs
- Added memoize function decorator to cache last previously passed function parameter
0.3.2
- Fixed issue with introspection API picking up validation methods
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
drizm-commons-0.3.2.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for drizm_commons-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49de78999ec4766e66e7b0a7c3ece423b258964e5c073733b4c30dbb884ee837 |
|
MD5 | 096326ee02dd4bf91edfe07117819729 |
|
BLAKE2b-256 | 27ffcd01ca2f79ee927aa5b44c7af06286c275539af03e0d8fc41006550683dc |