My python swiss army knife
Project description
My python swiss army knife.
Installing
Install and update using pip:
$ pip install -U pyshn
Usage
from pyshn.cpf import cpf
print(cpf(1))
# raises pyshn.cpf.CpfError: invalid number '1'
print(cpf(191))
# 000.000.001-91
print(cpf("191"))
# raises pyshn.cpf.CpfError: invalid format '191'.
print(cpf("00000000191"))
# 000.000.001-91
print(cpf("000000001/91"))
# 000.000.001-91
print(cpf("000.000.001-91"))
# 000.000.001-91
print(format(cpf(191)))
# 000.000.001-91
print(format(cpf(191), 'n'))
# 00000000191
print(format(cpf(191), 'N'))
# 000000001/91
print(format(cpf(191), 'chewbacca'))
# ValueError: Invalid format specifier
print(int(cpf(191)))
# 191
print(cpf(1, generate=True))
# 000.000.001-91
print(cpf("1", generate=True))
# pyshn.cpf.CpfError: invalid format '1'.
print(cpf("000000001", generate=True))
# 000.000.001-91
print(cpf("000.000.001", generate=True))
# 000.000.001-91
print(cpf(1, validate=False))
# 000.000.000-01
print(bool(cpf(1, validate=False)))
# False
print(bool(cpf(191, validate=False)))
# True
from random import random
print(cpf(int(random()*999_999_999), generate=True))
# 238.671.110-22
Links
PyPI Releases: https://pypi.org/project/pyshn/
Source Code: https://github.com/shneiderfku/pyshn/
Issue Tracker: https://github.com/shneiderfku/pyshn/issues/
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.
Source Distribution
pyshn-0.1.0.tar.gz
(4.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pyshn-0.1.0-py3-none-any.whl
(3.9 kB
view details)
File details
Details for the file pyshn-0.1.0.tar.gz.
File metadata
- Download URL: pyshn-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0f80e6a6fda96fd444dc69133d7741d18baa9e9a5d917711e93fdbaa8b13455
|
|
| MD5 |
0f7bcf115d0fd8ae83c72df20c0ec912
|
|
| BLAKE2b-256 |
2b4d1e839498b7c5a8b848296b5a5e79da16179daedbc608008c961ac8d530de
|
File details
Details for the file pyshn-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyshn-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fdf44c5a812233e4e1d0a7121bc2fa8528187b0bede6db57da9dcf73eb4f43e
|
|
| MD5 |
ebff0e4b794ec6d06ec8ca05fa9fd30e
|
|
| BLAKE2b-256 |
6d9bbefb51a66dd3cd42c41b4ef3f89ee99732eb435768211505de857bbc1132
|