Skip to main content

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

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyshn-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

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

Hashes for pyshn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a0f80e6a6fda96fd444dc69133d7741d18baa9e9a5d917711e93fdbaa8b13455
MD5 0f7bcf115d0fd8ae83c72df20c0ec912
BLAKE2b-256 2b4d1e839498b7c5a8b848296b5a5e79da16179daedbc608008c961ac8d530de

See more details on using hashes here.

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

Hashes for pyshn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fdf44c5a812233e4e1d0a7121bc2fa8528187b0bede6db57da9dcf73eb4f43e
MD5 ebff0e4b794ec6d06ec8ca05fa9fd30e
BLAKE2b-256 6d9bbefb51a66dd3cd42c41b4ef3f89ee99732eb435768211505de857bbc1132

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page