Skip to main content

Python utility package

Project description

from xml.etree.ElementTree import indentfrom sys import prefix

Tools

Python Utility Tools Library

Startup Info

This module print in stdout general info at startup. Should be added at the beginning of the main program or where you need to display this information:

  • examples:

    from tools.startup_info import startup_info
    startup_info()
    

    result:

    --------------------------
    2020-11-12 13:14:15.678901
    User: DemoUser
    Host: DemoUser-PC
    OS Platform: Windows-10-10.0.19020-SP0
    Python Version: 3.11.2 (tags/v3.11.2:bffe2c1, Jan 08 2020, 10:12:11) [MSC v.1936 64 bit (AMD64)]
    Implementation: CPython
    -----------------------
    

Common

This module contains tools for general use.

Attribute Manager

This class contains methods for managing class attributes taking in consideration real mangled name of each attribute.

  • examples:
    from tools.common import AttributeManager
    
    class SomeClass:
        __slots__ = ('__private_attr', '_protected_attr', 'public_attr')
        ...
        def as_static(self, attr_name: str):
            mangled_name = AttributeManager.get_name(obj=self, attr=attr_name)
            print(f'attribute_mangled_name: {mangled_name}')
            #
            found = AttributeManager.has_attribute(obj=self, attr=attr_name)
            print(f'found: {found}')
            #
            if not found:
                AttributeManager.set_attribute(obj=self, attr=attr_name, value=None)
            #
            value = AttributeManager.get_attribute(obj=self, attr=attr_name)
            print(f'value: {value}')
            pass
            
        def as_instance(self, attr_name: str):
            attr = AttributeManager(obj=self, attr=attr_name)
            #
            mangled_name = attr.name
            print(f'attribute_mangled_name: {mangled_name}')
            #
            found = attr.exists
            print(f'found: {found}')
            #
            if not found:
                attr.value = None
            #
            value = attr.value
            print(f'value: {value}')
            pass
        ...
    pass
    
Hide Big Content

This method tries to hide big content over a limit of characters.

  • examples:
    from tools.common import hide_big_content
    
    content = {
        'key': 'value',
        'l': [1, 'a', 'b'],
        's': 'aaa',
        't': (1, 2, 'a' * 5000)
    }
    print(f'content: {content}')
    processed = hide_big_content(value=content)
    print(f'processed: {processed}')
    
Mask password

This method tries to mask passwords from provided object.

  • examples:
    from tools.common import mask_password
    
    content = [
        1, 2, True,
        {
            'password': '12345',
            'pwd': 'x56',
            'pwd_lst': ['123', '345', '567']
        }
    ]
    print(f'content: {content}')
    processed = mask_password(value=content)
    print(f'processed: {processed}')
    
Get Location

Try to resolve file / method location. Can be used for template relative location

  • examples:
    from tools.common import get_location
    
    def func(): pass
    
    func_location = get_location(func=func)
    print(f'func_location: {func_location}')
    
    file_location = get_location(file=__file__)
    print(f'file_location: {file_location}')
    

Folders

This module was created to manage main folder operations.

  • examples:
    from tools.folders import Folder
    
    path = 'path/to/folder'
    
    if not Folder.exists(path=path):
        Folder.create(path='path/to/old-folder', recursive=True)
        
    Folder.remove(path='path/to/new-folder', recursive=True)
    

Files

This module was created to perform main file operations.

  • examples:
    from tools.files import File
    
    path = 'path/to/file'
    name = 'file-name.ext'
    
    if not File.exists(path=path, name=name):
        File.write(path=path, name=name, content=None)
    
    demo = File.read(path=path, name=name)
    print(f'Demo file: {demo}')
    
    locked = File.lock(path=path, name=name)
    print('File is locked')
    
    try:
        File.write(path=path, name=name, content=b'new-content')
    except Exception as exc:
        print(f'Something got wrong: {exc}')
    
    File.unlock(file=locked)
    print('File is free to use')
    
    File.remove(path=path, name=name)
    

Tables

This module was created to store data as a table, with data / column validation and filtering. Cells can be accessed by index or by key.

  • examples:
    from tools.tables import Table
    
    table = Table(
        table={
            'columns': ['col-1', 'col-2'],
            'data': [
                # row-1
                {'col-1': 1, 'col-2': 2},
                # row-2
                {'col-1': True, 'col-2': 'str'}
            ]
        }
    )
    print(f'table: {table}')
    
    filtered_1 = table.filter(exclude=('col-1',))
    print(f'filtered_1: {filtered_1}')
    
    filtered_2 = table.filter(include=('col-2',))
    print(f'filtered_2: {filtered_2}')
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

ruth_tools-2022.0.0-cp313-cp313-win_amd64.whl (242.3 kB view details)

Uploaded CPython 3.13Windows x86-64

ruth_tools-2022.0.0-cp313-cp313-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

ruth_tools-2022.0.0-cp313-cp313-musllinux_1_2_i686.whl (1.4 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ i686

ruth_tools-2022.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

ruth_tools-2022.0.0-cp313-cp313-macosx_11_0_arm64.whl (258.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ruth_tools-2022.0.0-cp312-cp312-win_amd64.whl (245.0 kB view details)

Uploaded CPython 3.12Windows x86-64

ruth_tools-2022.0.0-cp312-cp312-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

ruth_tools-2022.0.0-cp312-cp312-musllinux_1_2_i686.whl (1.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

ruth_tools-2022.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ruth_tools-2022.0.0-cp312-cp312-macosx_11_0_arm64.whl (261.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ruth_tools-2022.0.0-cp311-cp311-win_amd64.whl (246.4 kB view details)

Uploaded CPython 3.11Windows x86-64

ruth_tools-2022.0.0-cp311-cp311-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

ruth_tools-2022.0.0-cp311-cp311-musllinux_1_2_i686.whl (1.3 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ i686

ruth_tools-2022.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ruth_tools-2022.0.0-cp311-cp311-macosx_11_0_arm64.whl (260.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file ruth_tools-2022.0.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e04506ae591c8b474e6c6072d36dd4dd5b781247c59b99a04433b2094c39332f
MD5 eb192c818b7db6e6a49e24c1a9ed3a84
BLAKE2b-256 2618aaacc3a62eeb0c90f6e523714edd1430d0c100b09ee07e9d8d6f620ff546

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 70343a55c83b71855e20c9de9f9578a8ab182b059b039e40167d7f43c5cbb264
MD5 253ca40b57efa174dbbca63ee80d81c7
BLAKE2b-256 4658a5d2ebf916f80eb85f7c0b9faf4f59dde92a3257e6a92886a775f200738b

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp313-cp313-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 72c8fa0914766791ad42c992029df73b71c739ff0bc76be3101fa3393ffa816d
MD5 2ffcb506ad18ac1c254ff49303ed617b
BLAKE2b-256 1b945a736cef365c01f39400a9f49172b948fbcafe942dc34ca0c588d02b381a

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 efd3dccb1ee3e057dac5a1b1cea45cc00d64c1bdb306e25a8c31b17c8da26159
MD5 b7b097665321215697ad3120575e06e2
BLAKE2b-256 f143ca4fc36c09d1661833e742f7aeb45a473f30d76b57e4a48b0f794479fc7b

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78ae74818ff98aaccee8776af78584d310e2f524ee5a77b2a11411582b697224
MD5 ba7790a5227e06f184cab49b553568f9
BLAKE2b-256 aac1eac3cdb9915c1cdb64ae6705751dc1eb891ba2a6b41185513b953978a418

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5c70c3a45c8fb38657b2ee0978b2d59dbce628e24f26190fd0001346a348b256
MD5 f3fa9d47a242d89b1614fbd083f57228
BLAKE2b-256 f89617f74bfa72b49c0c87cac881b1b926b4dbbbfa6a7e1da8ecb65c6c6c7405

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 708df5b5f75ea459fc2007c8dd5c70b3ec10375ade9e6d4ef84b3b91001e3993
MD5 93da8cb91aae833be9a7ad7263f00415
BLAKE2b-256 db346523b18c5eb76a229de58935f41837b78447e05a568ebd747cdca84fcaa5

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 eea215bdac229e67aeb4d486b8c055e4d20ebc5cf78a3615d10555943f6ad07e
MD5 987055636d4d8df3d4590f9be93e1d59
BLAKE2b-256 f132efcf052581bc1ed91ed1375a668b0e3360e1fab9782f42d58dc72fadea51

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 411c2d46cbe257f5ef5f4eae206f37fd79726a934aff5b72e27ae40d06604e67
MD5 8fbeef94b779b87169a5cf8050eb37c7
BLAKE2b-256 f534f35b723f6f082079ed5193c1e88c3a37483b86d27a9b169ed117ac9baa10

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 283917d7d9a4059e1b034e12e24bb21d1f033a6a53461a232c02f930a87215d0
MD5 cc696f48d4bc0ce8ee97353018f360d8
BLAKE2b-256 3dee6a45c4840e80eda031ab3cad6180becc81097b3990415fce96c9bf9740b0

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9dabd7c525470f0e4175af480b689779b4c5a59d03bb01fc18531120e2a37e26
MD5 38b603c198c62e74e7cc96e164c1cb85
BLAKE2b-256 20797894dc97ac9e80c5fd20fc5c688d8142314b738b6b6a98ff46fc89ea13a8

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4ff920de769e8a9129fcc5b3ebafaa42f6e58b8eef72aab4d1bdb8d8d82ae3af
MD5 16281687c54478e691467289a6036be3
BLAKE2b-256 61c277d11c3c252fd93b38bd8be90465ff52f40122d03b5ecd0fd3a1abe3ee60

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 875efcef3c8fdadabb465ddc9266fa4bd48be790740f6f35fef61e06f1528d87
MD5 be1be8ec60cf510071d21173c06f8177
BLAKE2b-256 043ccbcde41532050b20be9c87c1802cf6bac2fccb355e393a31574a9c71c4ba

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 40031dda74760c4aa5c5e6c16582099324d2c3e395e018959e1e575f63a4dc48
MD5 67775e9e344399dd86e58528ba1d5f2e
BLAKE2b-256 b05de2c68fab22018b33844bf5f2dc16ab10b955b1cac46b352ee4098b28c2ed

See more details on using hashes here.

File details

Details for the file ruth_tools-2022.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ruth_tools-2022.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 842ea55aad02cabafedc2979c6383b49c0dffc507fd091446a48d7f9e2bebfbb
MD5 60befae1f12d39c40afe079a8e5216ea
BLAKE2b-256 ba8e453ecab5431049b1d1be883bb939edd7090416dce76f5be4c4490513ed79

See more details on using hashes here.

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