Skip to main content

Utilities for lazy Python developers

Project description

plazy

Utilities for lazy Python developers

INSTALLATION

pip install plazy

PLAZY FEATURES

Unique list and string

Plazy version: 0.1.3+

Turn list or tuple into unique list/tuple, keep order or sort the list/tuple.

import plazy

if __name__ == "__main__":
    sample_t = (7, 3, 5, 3, 3, 7, 9)
    unique_t = plazy.unique(seq=sample_t) # (7, 3, 5, 9)

    sample_l = [7, 3, 5, 3, 3, 7, 9]
    unique_l = plazy.unique(seq=sample_l) # [7, 3, 5, 9]

    unique_rt = plazy.unique(seq=sample_t, sort=True, reverse=True) # (9, 7, 5, 3)

Base64 encode and decode for string

Plazy version: 0.1.3+

Base64 encode and decode for string.

import plazy

if __name__ == "__main__":
    encoded_val = plazy.b64encode('plazy') # cGxhenk=
    encoded_val = plazy.b64encode('plazy', pretty=True) # cGxhenk => Note: this string cannot be decoded!
    original_val = plazy.b64decode('cGxhenk=') # plazy

Random String

Plazy version: 0.1.2+

Generate random string.

import plazy

if __name__ == "__main__":
    rstring = plazy.random_string() # iVr3FY
    rstring = plazy.random_string(upper=False) # mzvn7b
    rstring = plazy.random_string(size=8) # XqVDuu5R
    rstring = plazy.random_string(size=6, digit=True, lower=False, upper=False) # 763099
    rstring = plazy.random_string(size=6, digit=False, lower=True, upper=False) # djzcch
    rstring = plazy.random_string(size=6, digit=False, lower=False, upper=True) # BGBMQN

Read Text File

Plazy version: 0.1.2+

Read lines of text file, eliminate redundant characters of each line, skip the empty lines.

import plazy

if __name__ == "__main__":
    lines = plazy.read_txt(path='/home/video-list.txt')
    print(lines) # ['<line#1>', '<line#2>', '<line#3>', ...]

List Files

Plazy version: 0.1.1+

List files recursively in directory.

import plazy

if __name__ == "__main__":
    files = plazy.list_files(root='images',
                            filter_func=lambda x : True if x.endswith('.jpg') else False,
                            is_include_root=False)
    print(files) # ['1.jpg', '2.jpg', '_sub_/4.jpg']

Auto Assign

Plazy version: 0.1.0+

Assign attributes of class with the passed arguments automatically.

import plazy

class Cat(object):
    @plazy.auto_assign
    def __init__(self, name, owner='Kyzas'):
        pass

if __name__ == "__main__":
    my_cat = Cat('Kittie')
    print(my_cat.name)      # Kittie
    print(my_cat.owner)     # Kyzas

CONTRIBUTING

  • Step 1. Fork on dev branch.
  • Step 2. Install pre-commit on the local dev environment.
pip install pre-commit
pre-commit install
  • Step 3. Write test case(s) for the new feature or the bug.
  • Step 4. Write code to pass the tests.
  • Step 5. Make sure that the new code passes all the pre-commmit conditions.
pre-commit run -a
  • Step 6. Create pull request.

Project details


Download files

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

Files for plazy, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size plazy-0.1.3-py2.py3-none-any.whl (5.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size plazy-0.1.3.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page