Skip to main content

🔥Reusable common utilities, interfaces and implementations for python projects.

Reason this release was yanked:

Typing info outdated

Project description

vt-commons

PyPI - Python Version PyPI - Types GitHub License 🔧 test 💡 typecheck 🛠️ lint 📊 coverage 📤 Upload Python Package PyPI - Version


🔥Reusable common utilities, interfaces and implementations for python projects.


A fully typed library for common methods, utils, interfaces and implementations for python projects.

Install

  pip install vt-commons

Usage examples

  • Check for OS

    from vt.utils.commons.commons.os import is_windows
    
    windows = is_windows()
    

    Check in vt.utils.commons.commons.os and documentation for more functions and utilities related to OS.

  • Perform some operation on a root directory

    from vt.utils.commons.commons.op import RootDirOp, CWDRootDirOp, RootDirOps
    from pathlib import Path
    from typing import override
    
    class MyRootDirectoryOperation(RootDirOp):
    ...
    
    @override
    @property
    def root_dir(self)-> Path:
        return Path('path', 'to', 'my', 'root-directory')
    
    certain_root_dir_operation: CWDRootDirOp = RootDirOps.from_path(Path('path', 'to', 'my', 'root-directory'))
    

    Check in vt.utils.commons.commons.op and documentation for more functions and utilities related to operations.

  • Perform state operations

    from vt.utils.commons.commons.state import DoneMarker
    from typing import override
    
    # Track state by marking done
    class MyStateManager(DoneMarker[int]):
    def __init__(self, *args, **kwargs):
        self.id_state = {1: False}
        ...
    
    @override
    def mark_done(self, _id: int)-> bool:
        # mark done for _id
        if self.id_state[_id] is True:
            return False
        self.id_state[_id] = True
        return True
    

    Check in vt.utils.commons.commons.state and documentation for more functions and utilities related to tracking state.

  • Check if a value is MISSING

    from vt.utils.commons.commons.core_py import MISSING, Missing, is_missing
    
    def some_operation(arg: Missing = MISSING):
    """
    ``MISSING`` can be used as a default value sentinel when ``None`` is a valid value for arg.
    """
    arg = 10 if is_missing(arg) else arg
    ...
    

    Check in vt.utils.commons.commons.core_py and documentation for more functions and utilities related to function management.

  • Query and operate on iterables

    >>> from vt.utils.commons.commons.collections import get_first_true, get_first_non_none
    
    >>> assert 3 == get_first_true([1, 3, 5, 7, 2, 1], 8, lambda x: x>2)
    >>> assert 10 == get_first_non_none([None, None, 10, 2, 6], 9)
    

    Check in vt.utils.commons.commons.collections and documentation for more functions and utilities related to collection management.

  • String operations

    >>> from vt.utils.commons.commons.string import generate_random_string
    
    >>> generate_random_string()  #doctest: +ELLIPSIS
    '...'
    

    Check in vt.utils.commons.commons.string and documentation for more functions and utilities related to strings

Contribute

Want to contribute?

Checkout Guidelines for contributions.

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

vt_commons-0.0.1.dev5.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vt_commons-0.0.1.dev5-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file vt_commons-0.0.1.dev5.tar.gz.

File metadata

  • Download URL: vt_commons-0.0.1.dev5.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vt_commons-0.0.1.dev5.tar.gz
Algorithm Hash digest
SHA256 8f6aea908c21853b3cfe4c922501f9e3b6d4fea2a1f370f490864c177d9d78b1
MD5 00176fd6191ce0162937ecf096900e35
BLAKE2b-256 9ebee1bc7d8173c8146b46d0a3077d539616940985087418558a4c2d95bc0688

See more details on using hashes here.

Provenance

The following attestation bundles were made for vt_commons-0.0.1.dev5.tar.gz:

Publisher: python-publish.yml on Vaastav-Technologies/py-commons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vt_commons-0.0.1.dev5-py3-none-any.whl.

File metadata

File hashes

Hashes for vt_commons-0.0.1.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 b3e10f7849f632e7ec4a7429b74e0c31c07f9d471f3be21fca152c6147d07b92
MD5 f48dee56c65ba83c052213de60485ade
BLAKE2b-256 c59fbddf53881c92cd7d8f887a65a0a3743a2a45e2ba71547fbd7c7a378a204c

See more details on using hashes here.

Provenance

The following attestation bundles were made for vt_commons-0.0.1.dev5-py3-none-any.whl:

Publisher: python-publish.yml on Vaastav-Technologies/py-commons

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page