isabelapnt / pycpfcnpj

Python module for brazilian register numbers for persons (CPF) and companies (CNPJ).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pycpfcnpj

Description

Python module for brazilian register numbers for persons (CPF) and companies (CNPJ).

Python 3 ready!

Build Status codecov PyPI version

How to install

Now you can install this module with pip! Yeah! :D

pip install pycpfcnpj

Quick Start

To use pycpfcnpj is simples like as every python module shoud be!

from pycpfcnpj import cpfcnpj
cpf_number = '11144477735'
masked_cpf_number = '111.444.777-35'
cnpj_number = '11444777000161'
masked_cnpj_number = '11.444.777/0001-61'

print cpfcnpj.validate(cpf_number)
print cpfcnpj.validate(masked_cpf_number)
print cpfcnpj.validate(cnpj_number)
print cpfcnpj.validate(masked_cnpj_number)

Expected output:
>>>True
>>>True
>>>True
>>>True

Simple like that. =)

You can use, as well, the cpf and cnpj packages. The cpfcnpj is like a Facade to the other modules. Make yourself confortable.

Oh, fork and contribute either if you want to.

Obs.: There is no dependencies.

Oh, and before I forget, You can generate, only and only for test purposes, a CPF or CNPJ number using the 'gen' module. Easy like above:

from pycpfcnpj import gen
gen.cpf()
gen.cnpj()

Expected output:
>>> 49384063495
>>> 20788274885880

Have fun!

In portuguese:

Módulo python para validar números de CPF e CNPJ.

Como instalar:

Agora você pode instalar o pycpfcnpj usando o pip!\m/

pip install pycpfcnpj

Como usar

from pycpfcnpj import cpfcnpj
cpf_number = '11144477735'
masked_cpf_number = '111.444.777-35'
cnpj_number = '11444777000161'
masked_cnpj_number = '11.444.777/0001-61'

print cpfcnpj.validate(cpf_number)
print cpfcnpj.validate(cpf_number_mascara)
print cpfcnpj.validate(cnpj_number)
print cpfcnpj.validate(cnpj_number_mascara)

Expected output:
>>>True
>>>True
>>>True
>>>True

Simples assim! Você também pode usar os pacotes internos que tratam em separado os números de CPF e CNPJ. O módulo 'cpfcnpj' é um tipo de interface para os módulos mais especificos e se encarrega de saber quando você está passando um CPF ou um CNPJ.

Fique à vontade em contribuir com o projeto ou da maneira que quiser. Ah, sim: pure python (sem dependências ;) ).

Ah, e antes que eu me esqueça, você pode gerar, só e apenas somente para fins de teste, um número de CPF ou CNPJ utilizando o módulo 'gen'. Fácil como acima:

from pycpfcnpj import gen
gen.cpf()
gen.cnpj()

Expected output:
>>> 49384063495
>>> 20788274885880

Divirta-se!

Changelog

1.1

  • Handles CPF and CNPJ numbers with punctuation marks (Trata números de CPF e CPNJ com sinais de pontuação)

1.2

  • Use sys rather than six to check python's version and keeps this project 100% free of dependencies.

About

Python module for brazilian register numbers for persons (CPF) and companies (CNPJ).

License:MIT License


Languages

Language:Python 100.0%