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.1.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.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file pyshn-0.1.1.tar.gz.

File metadata

  • Download URL: pyshn-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a64ee4e79f3667103579e46fc8ea8ebe0387d5d778e086304efcd639890c3189
MD5 3e56745908e2a5d86e6b10a8c01aabae
BLAKE2b-256 a7a8b4ddc89c11ee830b323a17077d2d570d64a8c047cc60fed69ccedc7513a9

See more details on using hashes here.

File details

Details for the file pyshn-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyshn-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02de4960ef2d8f350b33f0316307cc29fa491e98771b5f6ccc0a6b2fecd2529f
MD5 4f14f604c3c4694f95d8a36c4c27f56a
BLAKE2b-256 355e4efb65a69b200bab832039b4a002763128150969d2ca594f5ea3e4a8a8c6

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