brazilian_ids.functions.real_state package

Submodules

brazilian_ids.functions.real_state.cno module

Functions to handle Brazilian CNO identifier.

CNO means “Cadastro Nacional de Obras” in Brazilian Portuguese, and it is a database that contains information about the all civilian real state constructions and can be associate with a person (CPF) or a company (CNPJ).

The CNO ID replaces the old CEI (Cadastro Específico do INSS) ID, but basically the functions are the same.

See also:

exception brazilian_ids.functions.real_state.cno.InvalidCnoError(cno)

Bases: InvalidCnoTypeMixin, InvalidIdError

Exception for invalid CNO errors

Parameters:

cno (str)

Return type:

None

exception brazilian_ids.functions.real_state.cno.InvalidCnoLengthError(cno, expected_digits=11)

Bases: InvalidCnoTypeMixin, InvalidIdLengthError

Exception for invalid CNO length error.

Parameters:
  • cno (str)

  • expected_digits (int)

Return type:

None

class brazilian_ids.functions.real_state.cno.InvalidCnoTypeMixin

Bases: object

Mixin class for CNO errors.

id_type()
brazilian_ids.functions.real_state.cno.format(cno)

Applies typical 00.000.00000/00 formatting to CEI.

Parameters:

cno (str)

Return type:

str

brazilian_ids.functions.real_state.cno.is_valid(cno, autopad=True)

Check whether CEI is valid. Optionally pad if too short.

Parameters:
  • cno (str)

  • autopad (bool)

Return type:

bool

brazilian_ids.functions.real_state.cno.pad(cno, validate_after=False)

Takes a CEI that probably had leading zeros and pads it.

Parameters:

cno (str)

Return type:

str

brazilian_ids.functions.real_state.cno.random(formatted=True)

Create a random, valid CNO identifier.

Parameters:

formatted (bool)

Return type:

str

brazilian_ids.functions.real_state.cno.verification_digit(cno, validate_length=False)

Calculate check digit from iterable of integers.

Parameters:
  • cno (str)

  • validate_length (bool)

Return type:

int

brazilian_ids.functions.real_state.sql module

Functions to handle SQL codes.

Do not confuse SQL with the name of the query language for relational databases.

SQL in this context means “Setor, Quadra e Lote” in Brazilian Portuguese, and it’s used to provide a unique identifier to a real state property and is also related to the IPTU tax from governament.

SQL is also known as “número do contribuinte” or “cadastro do imóvel”.

exception brazilian_ids.functions.real_state.sql.InvalidSqlError(sql)

Bases: InvalidSqlTypeMixin, InvalidIdError

Exception for invalid SQL errors

Parameters:

sql (str)

Return type:

None

exception brazilian_ids.functions.real_state.sql.InvalidSqlLengthError(sql, expected_digits=10)

Bases: InvalidSqlTypeMixin, InvalidIdLengthError

Exception for invalid SQL length error.

Parameters:
  • sql (str)

  • expected_digits (int)

Return type:

None

class brazilian_ids.functions.real_state.sql.InvalidSqlTypeMixin

Bases: object

Mixin class for SQL errors.

id_type()
brazilian_ids.functions.real_state.sql.format(sql)

Format the SQL string as NNN.NNN.NNNN-N.

If you have a SQL which length is less than EXPECTED_DIGITS, than use pad with it before calling format to avoid the InvalidSqlError exception.

Parameters:

sql (str)

Return type:

str

brazilian_ids.functions.real_state.sql.is_valid(sql)

Check if a given SQL is valid or not.

Non-numeric characters will be removed before testing.

Parameters:

sql (str)

Return type:

bool

brazilian_ids.functions.real_state.sql.pad(sql)

Includes 0 at the left of a SQL which length is less than EXPECTED_DIGITS.

Parameters:

sql (str)

Return type:

str

brazilian_ids.functions.real_state.sql.verification_digit(sql, validate_length=False)

Calculate the verification digit needed to make a SQL code value.

If you have a SQL which length is less than EXPECTED_DIGITS, than use pad first in it, otherwise the exception InvalidSqlLengthError will be raised (if validate_Length is True) or the digit calculated will be just invalid.

Parameters:
  • sql (str)

  • validate_length (bool)

Return type:

str

Module contents