Identifiers
rigour.ids
Handling of person, organisation and object identifiers. This module contains a collection of validation
and formatting tools for identifiers. The IdentifierFormat class is the base class for all identifier formats,
and it provides a common interface for validation and formatting.
Currently, identifers can be accessed using short aliases, such as "imo" or "isin". In the future, we will
need to introduce a proper, structured identification scheme for identifiers, with qualifiers for country
(e.g. ru:nalog:inn, us:sam:uei).
BIC
Bases: IdentifierFormat
BIC (ISO 9362 Business identifier codes).
Source code in rigour/ids/stdnum_.py
CNPJ
Bases: IdentifierFormat
Cadastro Nacional de Pessoas Jurídicas, Brazilian national companies identifier
Source code in rigour/ids/stdnum_.py
CPF
Bases: IdentifierFormat
Cadastro de Pessoas Físicas, Brazilian national identifier
Source code in rigour/ids/stdnum_.py
FIGI
Bases: IdentifierFormat
A FIGI number for a security, as managed by OpenFIGI.
Source code in rigour/ids/stdnum_.py
FormatSpec
IBAN
Bases: IdentifierFormat
An IBAN number for a bank account.
Source code in rigour/ids/stdnum_.py
IMO
Bases: IdentifierFormat
An IMO number for a ship or a shipping company.
Ship and company IMO numbers are both seven digits but use different check digit algorithms; this format admits both. Use is_valid_vessel or is_valid_company when the value must belong to one specific scheme, e.g. when minting scheme-specific entity IDs.
Extraction considers digit runs of five to seven digits, preferring longer
runs, then runs carrying an IMO prefix, then earlier ones; the first
candidate that passes a checksum wins. Runs shorter than seven digits are
left-padded with zeros, since data sources commonly strip leading zeros
from IMO fields. The all-zero value is rejected.
Source code in rigour/ids/imo.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
format(value)
classmethod
Format the given value as an IMO number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
A pre-validated IMO number. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The value with an |
Source code in rigour/ids/imo.py
is_valid(text)
classmethod
Determine if the given text contains a valid IMO number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
A string that may contain an IMO number. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if an IMO number valid in either checksum scheme can be |
bool
|
extracted from the text. |
Source code in rigour/ids/imo.py
is_valid_company(text)
classmethod
Determine if the given text contains a valid company IMO number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
A string that may contain an IMO number. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if an IMO number valid in the company checksum scheme can be |
bool
|
extracted from the text. |
Source code in rigour/ids/imo.py
is_valid_vessel(text)
classmethod
Determine if the given text contains a valid ship IMO number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
A string that may contain an IMO number. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if an IMO number valid in the vessel checksum scheme can be |
bool
|
extracted from the text. |
Source code in rigour/ids/imo.py
normalize(text)
classmethod
Extract and normalize an IMO number from the given text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
A string that may contain an IMO number. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The number in |
str | None
|
checksum-valid IMO number. |
Source code in rigour/ids/imo.py
INN
Bases: IdentifierFormat
Russian tax identification number.
Source code in rigour/ids/stdnum_.py
ISIN
Bases: IdentifierFormat
An ISIN number for a security.
Source code in rigour/ids/stdnum_.py
IdentifierFormat
Base class for identifier types.
Source code in rigour/ids/common.py
LEI
Bases: IdentifierFormat
Legal Entity Identifier (ISO 17442)
Source code in rigour/ids/stdnum_.py
NPI
Bases: IdentifierFormat
National Provider Identifier.
Source code in rigour/ids/npi.py
is_valid(text)
classmethod
Determine if the given string is a valid NPI.
Source code in rigour/ids/npi.py
normalize(text)
classmethod
Normalize the given string to a valid NPI.
Source code in rigour/ids/npi.py
OGRN
Bases: IdentifierFormat
Primary State Registration Number (Russian company registration).
Source code in rigour/ids/ogrn.py
is_valid(text)
classmethod
Determine if the given string is a valid OGRN.
Source code in rigour/ids/ogrn.py
normalize(text)
classmethod
Normalize the given string to a valid OGRN.
Source code in rigour/ids/ogrn.py
SSN
Bases: IdentifierFormat
US Social Security Number
Source code in rigour/ids/stdnum_.py
StrictFormat
Bases: IdentifierFormat
A generic identifier type that applies harsh normalization.
Source code in rigour/ids/strict.py
UEI
Bases: IdentifierFormat
US GSA Unique Entity ID.
Source code in rigour/ids/uei.py
STRONG = False
class-attribute
instance-attribute
Marked false because the SAM database is massively duplicated, and entities in SAM conflate companies and their owners. This makes UEIs more like cluster IDs than unique entity identifiers.
is_valid(text)
classmethod
Determine if the given string is a valid NPI.
Source code in rigour/ids/uei.py
normalize(text)
classmethod
Normalize the given string to a valid NPI.
Source code in rigour/ids/uei.py
USCC
Bases: IdentifierFormat
Unified Social Credit Identifier, a Chinese national identifier
Source code in rigour/ids/stdnum_.py
WikidataQID
Bases: IdentifierFormat
A wikidata item identifier.
Source code in rigour/ids/wikidata.py
is_valid(text)
classmethod
normalize(text)
classmethod
Normalize the given string to a valid wikidata QID.
get_identifier_format(name)
cached
Get the identifier type class for the given format name.
get_identifier_format_names()
get_identifier_formats()
Get a list of all identifier formats.