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.2.0.tar.gz (6.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.2.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyshn-0.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for pyshn-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6d4b96ebcc85533b3b7e9d54df7f67a7dc6176eec0359b450f33a411a38bcea4
MD5 c49e44628c62490c0df8815c405d67d2
BLAKE2b-256 3b70c19af9d411ce28d5dd4c5fc8123f3292a9b32995971c3e0a45d9086c42fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyshn-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for pyshn-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e4713d6a92bf71c909bb9f3d81e5c09d470f5b3abbd5892737d4754a87868ee
MD5 c03578110ebec4d714b70233184673e9
BLAKE2b-256 fe16687bcc925f88bd6db091b03bcc82521f38341e90423ed593fe43dc186b1c

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