Skip to main content

srblib

a srbcheema1 production contributions welcome Open Source Love Build Status Build status HitCount

srblib is an umberalla python library to hold my useful python scripts which can be used in other projects.

Its just not a library. Its a perspective.

Installation

  • Use pip to install, user --user flag
python3 -m pip install --user srblib

Build from Source

  • Clone the repository and checkout to stable commit
git clone https://github.com/srbcheema1/srblib
cd srblib
git checkout <latest_version say: v0.0.x>
  • install requirements
python3 -m pip install --user -r requirements.txt
  • Install srblib
python3 setup.py install --user
  • Building Source Distribution
python3 setup.py sdist

Classes Offered

  • Colour - A class with color names and a static print function which prints coloured output to stderr
    Colour.print(message,Colour.RED) # for foreground as red
    Colour.print(message,Colour.FULLGREEN) # for background as green
    Colour.print(message,Colour.FULLGREEN+Colour.RED) # for background as fullgreen and foreground as RED
  • Email - A class to send Emails
    a = Email()
    a.fromaddr = 'sender@gmail.com'
    a.toaddr = 'receiver@gmail.com'
    a.password = 'password'
    a.body = "test mail"
    a.subject = "test subject"
    a.send()
  • SrbBank - A class to store things for later use of a program. can act as a database
    a = SrbBank('db_name') #say the db_name is your database name
    a['hello'] = "world"
    b = SrbBank('db2','password')
    b['hello'] = "peeps"
    # EXIT THE CODE AND START NEW SESSION
    a = SrbBank('db_name')
    print(a['hello']) # 'world'
    b = SrbBank('db2','password')
    print(b['hello']) # 'peeps'
  • SrbJson - A class to use json file more easily
    a = SrbJson('json/path')
    a['hello'] = 'world'
    # EXIT THE CODE AND START NEW SESSION
    a = SrbJson('json/path')
    print(a['hello']) # 'world'
  • Tabular - A class to user tabular data and read write json,xlsx,csv files
    a = Tabular('path/to/file') # can take files with extension as csv,json,xlsx
    print(a) # prints table in tabular form
    data = a.matrix # get data in form of list of lists i.e. matrix
    json_data = a.json # get data in form of list of dictionaries i.e. json
    print(a[1]['name']) # here name is the attribute used to name the columns
    print(a[0]) # prints attributes
    print(a[1]) # prints 1st row (0 based)
    print(a['name']) # prints column with attribute 'name'
    a.write_xls('output/path')
    a.write_csv('output/path')
    a.write_json('output/path')

    NOTE: it reads blank and empty cells from excel file as None
    NOTE: to read excel file in strict mode please call obj.load_xls(path,strict=True)
  • Module - A class to import a file with variable path
    a = Module('/path/to/file')
    a.function_in_that_file()
    print(a.variable_in_that_file)
  • Soup - A class to help in scrapping, argument should be a url or BeautifulSoup object
    soup = BeautifulSoup('<p><div class="good">hello</div><div>world</div></p>','html.parser')
    a = Soup(soup)
    print(a) # prints it in pretty way
    b = a['div',{'class':'good'}] # [<div class="good">hello</div>]
    b = a[lambda tag: tag.name == 'div'] # [<div class="good">hello</div>, <div>world</div>]

    a = Soup('http://gitub.com/srbcheema1')
    b = a['div'][1]['p'] # cascading in [] operators they work similar to find_all function, save space
    text_output = a['div'][1]['p'].text # we can call any function or variable that we could call on soup
    soup = b.soup # get original soup object

Functions Offered

  • abs_path - returns absolute path of a path given. works on windows as well as linux.
  • get_os_name - returns OS name. values are windows, linux or mac
  • is_installed - checks if the following application is installed on machine or not
  • file_extension - returns back the extention of a file from filepath, may return '' if no ext
  • file_name - returns filename from a filepath
  • remove - removes a path recursively. it deletes all files and folders under that path
  • verify_file - verify that a file exists. if not it will create one. also creates parents if needed
  • verify_folder - verify that a folder exists. creates one if not there. also creates parents if needed
  • similarity - returns percentage of similarity in two strings.
  • str_hash - hashing a string
  • path_hash - hashing a full path

Variables Offered

  • debug - a boolean whose value can be changed in ~/.config/srblib/debug.json
  • on_windows - a boolean with value True is running on windows
  • on_ci - a boolean with value True is running on CI

Contact / Social Media

Github LinkedIn Facebook

Developed by

Developer / Author: Srb Cheema

Metadata

Release files for srblib 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for srblib 0.1.5
File Size Uploaded
srblib-0.1.5.tar.gz 16.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for srblib 0.1.5
File Interpreter ABI Platform
srblib-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 37.3 kB

Release files / srblib-0.1.5.tar.gz

Download URL srblib-0.1.5.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
223f1c42a09a355e16d9e6950c665a8d3d1eb52b9e495b97db0ca9c8944dfef2
BLAKE2b-256 checksum
How to use checksums
4d2612cb197fd406a95aea89ea911caa98e1610e52a3ac13a89505441658c364
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release files / srblib-0.1.5-py3-none-any.whl

Download URL srblib-0.1.5-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8699e9db80e48538d10292f7330449250bc0016d26b1f4cf3ebe15ecbc28f955
BLAKE2b-256 checksum
How to use checksums
c2af31c11e08cea14c26b4d86f09a0508fbe069623ba4e813009207fdfd568d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.5.6

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page