Skip to main content

Python3 commons for the Drizm organization

Project description

Python Commons

PyPI version

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

Project details


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.1.tar.gz (10.6 kB view hashes)

Uploaded Source

Built Distribution

drizm_commons-0.3.1-py3-none-any.whl (11.9 kB view hashes)

Uploaded Python 3

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