A python library by srb
Project description
# srblib
[](https://github.ocm/srbcheema1/srblib/issues)
[](https://github.com/srbcheema1)
[](https://github.com/srbcheema1/srblib)
[](http://hits.dwyl.io/srbcheema1/srblib)
**srblib** is an umberalla python library to hold my useful python scripts which can be used in other projects.
### Installation
#### Install using pip (Recommended)
- 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
```
- 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')
```
### 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
### Variables Offered
- debug - a boolean whose value can be changed in ~/.config/srblib/debug.json
### Contact / Social Media
[](https://github.com/srbcheema1/)
[](https://www.linkedin.com/in/srbcheema1/)
[](https://www.facebook.com/srbcheema/)
### Development by
Developer / Author: [Srb Cheema](https://github.com/srbcheema1/)
[](https://github.ocm/srbcheema1/srblib/issues)
[](https://github.com/srbcheema1)
[](https://github.com/srbcheema1/srblib)
[](http://hits.dwyl.io/srbcheema1/srblib)
**srblib** is an umberalla python library to hold my useful python scripts which can be used in other projects.
### Installation
#### Install using pip (Recommended)
- 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
```
- 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')
```
### 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
### Variables Offered
- debug - a boolean whose value can be changed in ~/.config/srblib/debug.json
### Contact / Social Media
[](https://github.com/srbcheema1/)
[](https://www.linkedin.com/in/srbcheema1/)
[](https://www.facebook.com/srbcheema/)
### Development by
Developer / Author: [Srb Cheema](https://github.com/srbcheema1/)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Built Distribution
Close
Hashes for srb_lib_004-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f02ad4326efc3dcf1731865b0e10423353dbc95ab5aa2adc322d41e7581a28a |
|
MD5 | ab5cce4b121070f0c8ed1ceaef5f0575 |
|
BLAKE2-256 | 98d597f805c92fa90a4598402d6fb3d924fc32b92cce3afafb6056a7e5d4dffc |