Privex Python Helpers’s documentation¶
Welcome to the documentation for Privex’s Python Helpers - a small, open source Python 3 package containing a variety of functions, classes, exceptions, decorators and more - each of which would otherwise be too small to maintain in an individual package.
This documentation is automatically kept up to date by ReadTheDocs, as it is automatically re-built each time a new commit is pushed to the Github Project
Contents
Quick install¶
Installing with Pipenv (recommended)
pipenv install privex-helpers
Installing with standard pip3
pip3 install privex-helpers
Python Module Overview¶
Privex’s Python Helpers is organised into various sub-modules to make it easier to find the functions/classes you want to use, and to avoid having to load the entire module (though it’s lightweight).
With the exception of privex.helpers.django
(Django gets upset if certain django modules are imported before
it’s initialised), all functions/classes are imported within the __init__
file, allowing you to simply type:
from privex.helpers import empty, run_sync, asn_to_name
Instead of having to import the functions from each individual module:
from privex.helpers.common import empty
from privex.helpers.asyncx import run_sync
from privex.helpers.net import asn_to_name
Below is a listing of the sub-modules available in privex-helpers
with a short description of what each module
contains.
Functions and classes related to working with Python’s native asyncio support |
|
This module contains somewhat risky code that uses app introspection e.g. |
|
Helper functions/classes related to caching. |
|
Common functions and classes that don’t fit into a specific category |
|
Functions, classes and/or types which either are, or are related to Python variable storage types ( |
|
Various functions/classes which convert/parse objects from one type into another. |
|
Cryptography related helper classes/functions |
|
Class Method / Function decorators |
|
This module file contains Django-specific helper functions, to help save time when developing with the Django framework. |
|
Exception classes used either by our helpers, or just generic exception names which are missing from the standard base exceptions in Python, and are commonly used across our projects. |
|
Various helper functions/classes which depend on a certain package being installed. |
|
Various helper functions for use with Maxmind’s GeoIP2 Library |
|
Network related helper code |
|
This module handles connection objects for databases, APIs etc. |
|
Configuration options for helpers, and services they depend on, such as Redis. |
|
Helpers for setup.py, e.g. |
|
Helper functions and classes to ease the use |
|
All Documentation¶
- AsyncIO Helpers / Wrappers
- privex.helpers.black_magic
- Framework-independent Cache System
- Common/General Helpers
- ALPHANUM
- SAFE_CHARS
- IS_XARGS
- IS_XKWARGS
- T_PARAM
- T_PARAM_DICT
- T_PARAM_LIST
- INS_EMPTY
- _filter_params
- almost
- auto_list
- byteify
- call_sys
- camel_to_snake
- chunked
- construct_dict
- dec_round
- empty
- empty_if
- env_bool
- env_cast
- env_csv
- env_decimal
- env_int
- env_keyval
- extract_settings
- extract_type
- filter_form
- get_function_params
- get_return_type
- human_name
- inject_items
- io_tail
- is_false
- is_true
- parse_csv
- parse_keyval
- random_str
- reverse_io
- shell_quote
- stringify
- strip_null
- tail
- typing_to_base
- ErrHelpParser
- LayeredContext
- Collections (Data Structures + helpers)
- Object-like Dictionaries (dict’s)
- Dict-able NamedTuple’s
- What is a dictable_namedtuple and why use it?
- Importing dictable_namedtuple functions
- Creating a NEW dictable_namedtuple type and instance
- Converting an existing namedtuple instance into a dictable_namedtuple instance
- Converting an existing namedtuple type/class into a dictable_namedtuple type/class
- Module Contents
- privex.helpers.converters
- Cryptography - (en/de)crypt/sign/verify
- Decorators
- Django Helpers
- Exceptions (Use them in your project!)
- privex.helpers.extras
- GeoIP2 (Maxmind) Wrapper Module
- privex.helpers.net
- privex.helpers.plugin
- _get_all_threadstore
- _get_threadstore
- _set_threadstore
- clean_threadstore
- close_memcached_async
- close_redis
- close_redis_async
- configure_memcached_async
- configure_redis
- configure_redis_async
- connect_geoip
- connect_memcached_async
- connect_redis
- connect_redis_async
- get_geodbs
- get_geoip
- get_geoip_db
- get_memcached_async
- get_redis
- get_redis_async
- reset_geoip
- reset_memcached_async
- reset_redis
- reset_redis_async
- privex.helpers.settings
- Python Packaging Helpers (setuppy)
- Threading Helpers / Wrappers
- privex.helpers.types
- How to use the unit tests
- Unit Test List / Overview
- tests.asyncx
- tests.base
- tests.cache
- tests.general
- tests.general.test_general
- TestGeneral
- Methods
- setUp
- test_call_sys_async_read
- test_call_sys_async_write
- test_call_sys_read
- test_call_sys_write
- test_chunked
- test_filter_form_dict1
- test_filter_form_dict_cast
- test_human_name_class
- test_human_name_func
- test_human_name_str_bytes
- test_inject_items
- test_inject_items_2
- test_retry_on_err
- test_retry_on_err_return
- Attributes
- Methods
- TestGeneralAlmost
- TestGeneralExtractSettings
- Methods
- test_extract_settings_case_sensitive
- test_extract_settings_case_sensitive_fail
- test_extract_settings_case_sensitive_lowercase_keys
- test_extract_settings_case_sensitive_lowercase_keys_fail
- test_extract_settings_class
- test_extract_settings_class_instance
- test_extract_settings_class_instance_case_sensitive
- test_extract_settings_class_instance_case_sensitive_fail
- test_extract_settings_dict
- test_extract_settings_modules
- Attributes
- Methods
- TestGeneralTail
- TestGeneral
- tests.general.test_inspect
- tests.general.test_mocker
- tests.general.test_general
- tests.test_bool
- tests.test_cache
- tests.test_collections
- TestDictObject
- TestDictableNamedtuple
- TestIsNamedTuple
- Methods
- test_dictable_namedtuple
- test_dictable_namedtuple_plus_invalid
- test_dictable_plus_normal_namedtuple
- test_not_namedtuple_class
- test_not_namedtuple_dict
- test_not_namedtuple_float
- test_not_namedtuple_int
- test_not_namedtuple_list
- test_not_namedtuple_tuple
- test_real_namedtuple
- test_real_namedtuple_plus_invalid
- Attributes
- Methods
- TestOrderedDictObject
- tests.test_converters
- tests.test_crypto
- tests.test_extras
- tests.test_parse
- tests.test_rdns
- tests.test_net