jblib
Author: Justin Bard
This module was written to minimize the need to write the functions I use often.
INSTALL: python3 -m pip install jblib
The source code can be viewed here: https://github.com/ANamelessDrake/jblib
More of my projects can be found here: http://justbard.com
from jblib import cd
class cd()
Example:
with cd(directory):
print (os.getcwd())
print (os.getcwd()) ## Back at the originating directory on exit
from jblib import hilight
class hilight(string).color(highlight=True, bold=True)
Example:
print (hilight("Hello World").red(bold=True))
Or you could make an object:
text = hilight("Bar")
print ("Foo "+text.blue())
To return the original string:
print (text.string)
Available Colors:
red
green
yellow
blue
purple
teal
white
from jblib import convert_module
Module to convert various data
def convert_time_from_seconds(seconds_given)
Converts a seconds into minutes, hours and days.
def IP2Int(ip)
Converts a IPv4 address to a interger - This is useful to store IP addresses in databases
def Int2IP(ipnum)
Converts a interger back to an IPv4 address
def urlcode(url, encode=False)
Wrapper for urllib.parse.quote and urllib.parse.unquote.
From urllib docs - Replace special characters in string using the %xx escape. Letters, digits, and the characters '_.-' are never quoted. By default, this function is intended for quoting the path section of URL.
- https://docs.python.org/3.1/library/urllib.parse.html?highlight=urllib#urllib.parse.quote
from jblib import HTMLgen
Basic HTML generator
02/09/2019
class HTMLgen(head=False, tail=False, lang="en", docType="html")
FUNCTIONS:
title(self, title, scripts=None, css=None)
body.add(content)
tag(tag, content=False, close=True, cssclass=None)
image(src, alt=None, srcset=None, height=None, width=None, style=None, cssclass=None)
br() <-- Returns a </ br> tag
div(cssclass) <-- Not yet implemented
TODO:
Add a Table Class to allow dynamically built tables (cols and rows to be programmatically built)
Add a Div Builder
EXAMPLE:
page = HTMLgen(True, True)
page.title("This is the page Title", scripts="foo.js bar.js", css="styles.css nav.css")
page.body.add(HTMLgen.image("images/frontpage.jpg", width="100%"))
page.body.add(HTMLgen.tag("h1", "This is a header line"))
page.body.add("This is another line")
page.return_html()
```
<!DOCTYPE html>
<html lang="en">
<head>
<title>This is the page Title</title>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="nav.css">
<script src="foo.js"></script>
<script src="bar.js"></script>
</head>
<body>
<img src="images/frontpage.jpg" width="100%">
<h1>This is a header line</h1>
This is another line
</body>
</html>
```
from jblib import progress_bar
Progress Bar
02/25/2019
FUNCTIONS:
progress_bar(progress, barLength=50, text_field="Progress")
EXAMPLE:
counter = 0
for i in range(100):
counter += 1
i = counter/100
progress_bar(i, 50)
sleep(0.1)
Progress: [#########################-------------------------] 50.0%
from jblib import build_date_array
Build Date Arrays
02/27/2019
FUNCTIONS:
build_date_array(days=1, start_date=str(datetime.date.today()), date_format='%Y-%m-%d', mon=True, tues=True, wed=True, thur=True, fri=True, sat=True, sun=True, weekend=True):
EXAMPLE:
dates = build_date_array(days=7, weekend=False)
dates
['2019-02-27', '2019-02-28', '2019-03-01', '2019-03-02', '2019-03-03', '2019-03-05', '2019-03-06']
from jblib import mean_deviation
''' DESCRIPTION: This function takes a Pandas DataFrame column in and then returns a series of calculated mean deviations
FUNCTION:
mean_deviation(data, mean=None)
EXAMPLE:
data["MeanDeviation"] = pd.Series(mean_deviation(data['column']), index=data.index)
'''
from jblib import standard_deviation
''' DESCRIPTION: This function takes a Pandas DataFrame column in and then returns the calculated standard deviation
FUNCTION:
standard_deviation(data, mean=None)
EXAMPLE:
standard_dev = standard_deviation(data['column'])
'''
Metadata
Release files for jblib 1.6.35
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jblib-1.6.35.tar.gz | 7.3 kB | Without provenance | Details for jblib-1.6.35.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jblib-1.6.35-py3-none-any.whl | Python 3 | none | any | Details for jblib-1.6.35-py3-none-any.whl |
Total release size: 18.1 kB
Release files / jblib-1.6.35.tar.gz
| Download URL | jblib-1.6.35.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69a8a953c5cad1fd8a53c45083d9c0a45b98e2a7f965f906da25d624ca4dbe40
|
|
BLAKE2b-256 checksum How to use checksums |
dbbd07ed28ebff6d8014193f08e6472fcbfc005148af0a4a669b7741de2ff1eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
|
Release files / jblib-1.6.35-py3-none-any.whl
| Download URL | jblib-1.6.35-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f418d6c210494301cdae94c1c2a36ff75e5a8625b3a788b44e312dfb7b1535f8
|
|
BLAKE2b-256 checksum How to use checksums |
c1daaa76129e57665cf88f8a3f81622502a6ecacf142d77776e052bb080d7856
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
|
Security for jblib 1.6.35
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.