drizm-commons


Namedrizm-commons JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/drizm-team/python-commons
SummaryPython3 commons for the Drizm organization
upload_time2020-11-27 21:35:13
maintainerDominik Lewandowski
docs_urlNone
authorThaRising
requires_python>=3.8,<4.0
licenseMIT
keywords commons sqlalchemy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Commons
[![PyPI version](https://badge.fury.io/py/drizm-commons.svg)](https://badge.fury.io/py/drizm-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

### Google Cloud Tools

````python
from drizm_commons.google import force_obtain_id_token
from google.oauth2 import service_account


auth = service_account.IDTokenCredentials.from_service_account_file(
    "/path/to/svc.json",
    target_audience="https://example.com/"
)
token = force_obtain_id_token(auth)
# returns something like 'ey....', only access token
````

### Utilities

**Convinience Functions:**  
````python
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:**
````python
from drizm_commons.utils import Path

# Recursively delete a folder
path = Path(__file__).parent
path.rmdir(recursive=True)
````

**Cache last passed parameter:**
````python
from drizm_commons.utils import memoize


@memoize
def foo(a):
    return a


foo(3)  # 3
foo()  # 3
````

### Introspection

````python
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

### 0.3.3

- Added additional tests and bugfixes

### 0.3.4

- Added support for comments and
special character parsing to Tfvars

### 0.4.0

- Added method to force obtain
GoogleCloudPlatform Id-Tokens

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/drizm-team/python-commons",
    "name": "drizm-commons",
    "maintainer": "Dominik Lewandowski",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "dominik.lewandow@gmail.com",
    "keywords": "commons,sqlalchemy",
    "author": "ThaRising",
    "author_email": "kochbe.ber@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/51/e6/ce0b40a5c7f24ed72b56fe09c07850cbdea68c460c360aaf62da2fb4a7ad/drizm-commons-0.4.0.tar.gz",
    "platform": "",
    "description": "# Python Commons\n[![PyPI version](https://badge.fury.io/py/drizm-commons.svg)](https://badge.fury.io/py/drizm-commons)  \n\nThis package includes shared code used by\nthe Drizm organizations development team.  \n\nIt is not intended for public usage but you\nmay still download, redistribute or \nmodify it to your liking.\n\n## Usage\n\nBasic Install (utils only):  \n>pip install drizm-commons\n\n\nFull install (SQLAlchemy features available):  \n>pip install drizm-commons[sqla]\n\nImport like so:  \n*import drizm_commons*\n\n## Documentation\n\n### Google Cloud Tools\n\n````python\nfrom drizm_commons.google import force_obtain_id_token\nfrom google.oauth2 import service_account\n\n\nauth = service_account.IDTokenCredentials.from_service_account_file(\n    \"/path/to/svc.json\",\n    target_audience=\"https://example.com/\"\n)\ntoken = force_obtain_id_token(auth)\n# returns something like 'ey....', only access token\n````\n\n### Utilities\n\n**Convinience Functions:**  \n````python\nfrom drizm_commons.utils import *\n\n\n# Check whether function name is dunder\nis_dunder(\"__name__\")  # True\n\n# Check if a given string is a valid UUIDv4\nuuid4_is_valid(\"myvalue\")  # False\n\n# Check if a URL is valid and the contents URL-Safe\nurl_is_http(\"https://myapp.com/\")  # True\n\n# Get the current applications root path\nPath(get_application_root())\n````\n\n**Path with extra features:**\n````python\nfrom drizm_commons.utils import Path\n\n# Recursively delete a folder\npath = Path(__file__).parent\npath.rmdir(recursive=True)\n````\n\n**Cache last passed parameter:**\n````python\nfrom drizm_commons.utils import memoize\n\n\n@memoize\ndef foo(a):\n    return a\n\n\nfoo(3)  # 3\nfoo()  # 3\n````\n\n### Introspection\n\n````python\nfrom drizm_commons.inspect import SQLAIntrospector\n\n\ntable = SQLAIntrospector(my_table_instance)\n\n\"\"\" Attributes \"\"\"\ntable.tablename  # get the name of the table\ntable.classname  # get the classname of the declarative instance\ntable.columns  # get all SQLA fields of the class\ntable.column_attrs  # get all SQLA fields + property and hybrid_property of the class\n````\n\n## Changelog\n\n### 0.1.1\n\n- Added SQLAlchemy JSON Encoder\n- Fixed bugs related to the Introspection\nAPI\n- Added table registry\n- Added additional utilities\n\n### 0.1.2\n\n- Added get_root_path and recursive delete\nPath utilities\n- Fixed various bugs\n\n### 0.2.0\n\n- Added full test suite\n- Added testing tools\n- Revamped introspection API\n- Provided additional overrides for the\nSQL connection adapter\n\n### 0.2.1\n\n- Added support for datetime JSON\nencoding\n\n### 0.2.2\n\n- Improved in-code documentation\n- Integrated additional utils from\ndrizm-django-commons\n\n### 0.3.0\n\n- Added introspection capabilities \nfor property and SQLAlchemy's\nhybrid_property\n- SQLAEncoder now respects property\nand hybrid_property on SQLA declarative\ninstances\n- Additional customizability hooks\nfor custom fields or data handling\n- Support for JSON-Encoding table\ninstances\n- Added SQLA as optional dependency\n- Added additional testing utilities\n\n### 0.3.1\n\n- Improved code documentation\n- Added docs\n- Added memoize function decorator\nto cache last previously passed\nfunction parameter\n\n### 0.3.2\n\n- Fixed issue with introspection API\npicking up validation methods\n\n### 0.3.3\n\n- Added additional tests and bugfixes\n\n### 0.3.4\n\n- Added support for comments and\nspecial character parsing to Tfvars\n\n### 0.4.0\n\n- Added method to force obtain\nGoogleCloudPlatform Id-Tokens\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python3 commons for the Drizm organization",
    "version": "0.4.0",
    "split_keywords": [
        "commons",
        "sqlalchemy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "384c3f40948b9098831cdc8abc25d483",
                "sha256": "fba3fabe898684d326a3109d88d34f2e49f8945bd49fc162c6733e8f4b202374"
            },
            "downloads": -1,
            "filename": "drizm_commons-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "384c3f40948b9098831cdc8abc25d483",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 13527,
            "upload_time": "2020-11-27T21:35:14",
            "upload_time_iso_8601": "2020-11-27T21:35:14.557808Z",
            "url": "https://files.pythonhosted.org/packages/b3/e7/3ef992d56647a0c5fde8eb989e562233ab88ab6a10e890ff6e67a4e09cea/drizm_commons-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "c9280d6cabf2eb826ab2eaf8795210ba",
                "sha256": "bce8966a531672371b60be5e522ff343867420c4eb00c728a1c437ba7ff56b35"
            },
            "downloads": -1,
            "filename": "drizm-commons-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c9280d6cabf2eb826ab2eaf8795210ba",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 12242,
            "upload_time": "2020-11-27T21:35:13",
            "upload_time_iso_8601": "2020-11-27T21:35:13.160759Z",
            "url": "https://files.pythonhosted.org/packages/51/e6/ce0b40a5c7f24ed72b56fe09c07850cbdea68c460c360aaf62da2fb4a7ad/drizm-commons-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-11-27 21:35:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "drizm-team",
    "error": "Could not fetch GitHub repository",
    "lcname": "drizm-commons"
}
        
Elapsed time: 0.22602s