python-stdnum branch master updated. 1.6-22-gedaad05
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
python-stdnum branch master updated. 1.6-22-gedaad05
- From: Commits of the python-stdnum project <python-stdnum-commits [at] lists.arthurdejong.org>
- To: python-stdnum-commits [at] lists.arthurdejong.org
- Reply-to: python-stdnum-users [at] lists.arthurdejong.org
- Subject: python-stdnum branch master updated. 1.6-22-gedaad05
- Date: Mon, 11 Sep 2017 22:19:11 +0200 (CEST)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".
The branch, master has been updated
via edaad05a48c7bb4739723bf9e7a3759f9c3b5247 (commit)
via 0ce5d0b21bd36cef209d7574e2ef5215df3ceca6 (commit)
via e468c1beae5cdacbb05540e39a5924bbc7acc09f (commit)
via 1c276393d695f969f4600cb3adc49af71168d513 (commit)
from 2cc39ea459dcd712462113e12ceb5eda27de9ecb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=edaad05a48c7bb4739723bf9e7a3759f9c3b5247
commit edaad05a48c7bb4739723bf9e7a3759f9c3b5247
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Mon Sep 11 20:51:20 2017 +0200
Run flake8 from tox
diff --git a/setup.cfg b/setup.cfg
index c37a5d4..a223703 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -17,3 +17,8 @@ cover-min-percentage=100
[build_sphinx]
all_files = 1
+
+[flake8]
+ignore = D105,D205,D209,D302,D400,E501,E731,F401,F403,F405,Q001
+max-complexity = 15
+max-line-length = 120
diff --git a/tox.ini b/tox.ini
index 282c9ee..d67119e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,6 @@
[tox]
-envlist = {py26,py27,py34,py35,py36,pypy}
+envlist = py{26,27,34,35,36,py},flake8
+skip_missing_interpreters = True
[testenv]
deps = nose
@@ -7,3 +8,22 @@ deps = nose
commands = nosetests
setenv=
PYTHONWARNINGS=all
+
+[testenv:flake8]
+skip_install = true
+deps = flake8
+ flake8-author
+ flake8-blind-except
+ py{35,36}: flake8-bugbear
+ flake8-class-newline
+ flake8-commas
+ flake8-deprecated
+ flake8-docstrings
+ flake8-exact-pin
+ flake8-import-order
+ flake8-print
+ flake8-quotes
+ flake8-tidy-imports
+ flake8-tuple
+ pep8-naming
+commands = flake8 stdnum *.py
https://arthurdejong.org/git/python-stdnum/commit/?id=0ce5d0b21bd36cef209d7574e2ef5215df3ceca6
commit 0ce5d0b21bd36cef209d7574e2ef5215df3ceca6
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sun Sep 10 23:40:53 2017 +0200
Minor code improvements (mostly PEP8)
diff --git a/stdnum/bg/egn.py b/stdnum/bg/egn.py
index 959e309..56837b4 100644
--- a/stdnum/bg/egn.py
+++ b/stdnum/bg/egn.py
@@ -86,7 +86,7 @@ def validate(number):
if len(number) != 10:
raise InvalidLength()
# check if birth date is valid
- birth_date = get_birth_date(number)
+ get_birth_date(number)
# TODO: check that the birth date is not in the future
# check the check digit
if calc_check_digit(number[:-1]) != number[-1]:
diff --git a/stdnum/cz/dic.py b/stdnum/cz/dic.py
index 66ece03..25304a1 100644
--- a/stdnum/cz/dic.py
+++ b/stdnum/cz/dic.py
@@ -65,7 +65,7 @@ def calc_check_digit_special(number):
"""Calculate the check digit for special cases. The number passed
should not have the first and last digits included."""
check = sum((8 - i) * int(n) for i, n in enumerate(number)) % 11
- return str((8 - (10 - check) % 11 ) % 10)
+ return str((8 - (10 - check) % 11) % 10)
def validate(number):
diff --git a/stdnum/dk/cpr.py b/stdnum/dk/cpr.py
index ead77df..54117fa 100644
--- a/stdnum/dk/cpr.py
+++ b/stdnum/dk/cpr.py
@@ -97,7 +97,7 @@ def validate(number):
if len(number) != 10:
raise InvalidLength()
# check if birth date is valid
- birth_date = get_birth_date(number)
+ get_birth_date(number)
# TODO: check that the birth date is not in the future
return number
diff --git a/stdnum/es/cups.py b/stdnum/es/cups.py
index a2011e2..896240a 100644
--- a/stdnum/es/cups.py
+++ b/stdnum/es/cups.py
@@ -74,7 +74,7 @@ def format(number):
number[14:18],
number[18:20],
number[20:],
- )).strip()
+ )).strip()
def calc_check_digits(number):
diff --git a/stdnum/es/referenciacatastral.py b/stdnum/es/referenciacatastral.py
index 8b32082..129bb16 100644
--- a/stdnum/es/referenciacatastral.py
+++ b/stdnum/es/referenciacatastral.py
@@ -74,8 +74,7 @@ def format(number):
number[:7],
number[7:14],
number[14:18],
- number[18:]
- ])
+ number[18:]])
# The check digit implementation is based on the Javascript
diff --git a/stdnum/eu/nace.py b/stdnum/eu/nace.py
index 64743b0..01ce652 100644
--- a/stdnum/eu/nace.py
+++ b/stdnum/eu/nace.py
@@ -67,7 +67,7 @@ def info(number):
number = compact(number)
from stdnum import numdb
info = dict()
- for n, i in numdb.get('eu/nace').info(number):
+ for _n, i in numdb.get('eu/nace').info(number):
if not i:
raise InvalidComponent()
info.update(i)
diff --git a/stdnum/fr/nir.py b/stdnum/fr/nir.py
index bbd6bc6..992fb61 100644
--- a/stdnum/fr/nir.py
+++ b/stdnum/fr/nir.py
@@ -49,6 +49,14 @@ InvalidChecksum: ...
'253072B07300470'
>>> validate('253072A07300443')
'253072A07300443'
+>>> validate('253072C07300443')
+Traceback (most recent call last):
+ ...
+InvalidFormat: ...
+>>> validate('6546546546546703')
+Traceback (most recent call last):
+ ...
+InvalidLength: ...
>>> format('295109912611193')
'2 95 10 99 126 111 93'
"""
@@ -77,9 +85,9 @@ def validate(number):
"""Check if the number provided is valid. This checks the length
and check digits."""
number = compact(number)
- if not (number.isdigit() or (
- number[:5].isdigit() and number[7:].isdigit() and
- number[5:7] in ('2A', '2B'))):
+ if not number[:5].isdigit() or not number[7:].isdigit():
+ raise InvalidFormat()
+ if not number[5:7].isdigit() and number[5:7] not in ('2A', '2B'):
raise InvalidFormat()
if len(number) != 15:
raise InvalidLength()
@@ -99,5 +107,6 @@ def is_valid(number):
def format(number, separator=' '):
"""Reformat the number to the standard presentation format."""
number = compact(number)
- return separator.join((number[:1], number[1:3], number[3:5], number[5:7],
- number[7:10], number[10:13], number[13:]))
+ return separator.join((
+ number[:1], number[1:3], number[3:5], number[5:7], number[7:10],
+ number[10:13], number[13:]))
diff --git a/stdnum/fr/siren.py b/stdnum/fr/siren.py
index ce94841..ced8224 100644
--- a/stdnum/fr/siren.py
+++ b/stdnum/fr/siren.py
@@ -80,5 +80,4 @@ def to_tva(number):
return '%02d%s%s' % (
int(compact(number) + '12') % 97,
' ' if ' ' in number else '',
- number
- )
+ number)
diff --git a/stdnum/iban.py b/stdnum/iban.py
index 61d5eb8..c87caa8 100644
--- a/stdnum/iban.py
+++ b/stdnum/iban.py
@@ -59,7 +59,7 @@ _ibandb = numdb.get('iban')
_struct_re = re.compile(r'([1-9][0-9]*)!([nac])')
# cache of country codes to modules
-_country_modules = dict()
+_country_modules = {}
def compact(number):
diff --git a/stdnum/it/codicefiscale.py b/stdnum/it/codicefiscale.py
index 0e26722..b1b9b1f 100644
--- a/stdnum/it/codicefiscale.py
+++ b/stdnum/it/codicefiscale.py
@@ -139,7 +139,7 @@ def validate(number):
if calc_check_digit(number[:-1]) != number[-1]:
raise InvalidChecksum()
# check if birth date is valid
- birth_date = get_birth_date(number)
+ get_birth_date(number)
return number
diff --git a/stdnum/lv/pvn.py b/stdnum/lv/pvn.py
index 5ac0974..fbf81cb 100644
--- a/stdnum/lv/pvn.py
+++ b/stdnum/lv/pvn.py
@@ -100,7 +100,7 @@ def validate(number):
raise InvalidChecksum()
else:
# natural resident, check if birth date is valid
- birth_date = get_birth_date(number)
+ get_birth_date(number)
# TODO: check that the birth date is not in the future
if calc_check_digit_pers(number[:-1]) != number[-1]:
raise InvalidChecksum()
diff --git a/stdnum/numdb.py b/stdnum/numdb.py
index 40ebdb4..2b1a6e9 100644
--- a/stdnum/numdb.py
+++ b/stdnum/numdb.py
@@ -203,5 +203,5 @@ def get(name):
import codecs
reader = codecs.getreader('utf-8')
with reader(resource_stream(__name__, name + '.dat')) as fp:
- _open_databases[name] = db = read(fp)
+ _open_databases[name] = read(fp)
return _open_databases[name]
diff --git a/stdnum/ro/cnp.py b/stdnum/ro/cnp.py
index 6aab9ef..be815a2 100644
--- a/stdnum/ro/cnp.py
+++ b/stdnum/ro/cnp.py
@@ -84,7 +84,7 @@ def validate(number):
if len(number) != 13:
raise InvalidLength()
# check if birth date is valid
- birth_date = get_birth_date(number)
+ get_birth_date(number)
# TODO: check that the birth date is not in the future
# number[7:9] is the county, we ignore it for now, just check last digit
if calc_check_digit(number[:-1]) != number[-1]:
diff --git a/stdnum/util.py b/stdnum/util.py
index 3d4b04f..b04e2c0 100644
--- a/stdnum/util.py
+++ b/stdnum/util.py
@@ -137,7 +137,7 @@ def get_number_modules(base='stdnum'):
"""Yield all the module and package names under the specified module."""
__import__(base)
module = sys.modules[base]
- for loader, name, is_pkg in pkgutil.walk_packages(
+ for _loader, name, _is_pkg in pkgutil.walk_packages(
module.__path__, module.__name__ + '.'):
__import__(name)
module = sys.modules[name]
https://arthurdejong.org/git/python-stdnum/commit/?id=e468c1beae5cdacbb05540e39a5924bbc7acc09f
commit e468c1beae5cdacbb05540e39a5924bbc7acc09f
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sun Sep 10 23:40:04 2017 +0200
Make import ordering consistent
diff --git a/stdnum/ch/vat.py b/stdnum/ch/vat.py
index cc8f2b7..d6501f6 100644
--- a/stdnum/ch/vat.py
+++ b/stdnum/ch/vat.py
@@ -43,8 +43,8 @@ InvalidChecksum: ...
'CHE-107.787.577 IVA'
"""
-from stdnum.exceptions import *
from stdnum.ch import uid
+from stdnum.exceptions import *
def compact(number):
diff --git a/stdnum/cn/ric.py b/stdnum/cn/ric.py
index 316e97d..e528910 100644
--- a/stdnum/cn/ric.py
+++ b/stdnum/cn/ric.py
@@ -34,9 +34,7 @@ digit is the checksum.
import datetime
-from stdnum.exceptions import (
- ValidationError, InvalidLength, InvalidFormat, InvalidChecksum,
- InvalidComponent)
+from stdnum.exceptions import *
from stdnum.util import clean
diff --git a/stdnum/do/cedula.py b/stdnum/do/cedula.py
index cd7b81f..5b32969 100644
--- a/stdnum/do/cedula.py
+++ b/stdnum/do/cedula.py
@@ -36,9 +36,9 @@ InvalidFormat: ...
'224-0002211-1'
"""
+from stdnum import luhn
from stdnum.exceptions import *
from stdnum.util import clean
-from stdnum import luhn
# list of Cedulas that do not match the checksum but are nonetheless valid
diff --git a/stdnum/ee/ik.py b/stdnum/ee/ik.py
index bdc93ff..c21e1ac 100644
--- a/stdnum/ee/ik.py
+++ b/stdnum/ee/ik.py
@@ -37,8 +37,8 @@ datetime.date(1968, 5, 28)
import datetime
-from stdnum.util import clean
from stdnum.exceptions import *
+from stdnum.util import clean
def compact(number):
diff --git a/stdnum/ee/registrikood.py b/stdnum/ee/registrikood.py
index d5d379d..dad6980 100644
--- a/stdnum/ee/registrikood.py
+++ b/stdnum/ee/registrikood.py
@@ -47,9 +47,9 @@ Traceback (most recent call last):
InvalidComponent: ...
"""
+from stdnum.ee.ik import calc_check_digit
from stdnum.exceptions import *
from stdnum.util import clean
-from stdnum.ee.ik import calc_check_digit
def compact(number):
diff --git a/stdnum/es/nif.py b/stdnum/es/nif.py
index b392a3a..e2b87e9 100644
--- a/stdnum/es/nif.py
+++ b/stdnum/es/nif.py
@@ -42,7 +42,7 @@ InvalidChecksum: ...
'X5253868R'
"""
-from stdnum.es import dni, nie, cif
+from stdnum.es import cif, dni, nie
from stdnum.exceptions import *
from stdnum.util import clean
diff --git a/stdnum/fi/__init__.py b/stdnum/fi/__init__.py
index eab8d0d..4659040 100644
--- a/stdnum/fi/__init__.py
+++ b/stdnum/fi/__init__.py
@@ -22,5 +22,5 @@
# provide vat as an alias
from stdnum.fi import alv as vat
-from stdnum.fi import ytunnus as businessid
from stdnum.fi import hetu as personalid
+from stdnum.fi import ytunnus as businessid
diff --git a/stdnum/fi/hetu.py b/stdnum/fi/hetu.py
index 580fe6c..88230dd 100644
--- a/stdnum/fi/hetu.py
+++ b/stdnum/fi/hetu.py
@@ -40,8 +40,8 @@ InvalidComponent: ...
'131052A308T'
"""
-import re
import datetime
+import re
from stdnum.exceptions import *
from stdnum.util import clean
diff --git a/stdnum/gb/nhs.py b/stdnum/gb/nhs.py
index 137d7b7..3460010 100644
--- a/stdnum/gb/nhs.py
+++ b/stdnum/gb/nhs.py
@@ -41,8 +41,8 @@ InvalidChecksum: ...
'943 476 5870'
"""
-from stdnum.util import clean
from stdnum.exceptions import *
+from stdnum.util import clean
def compact(number):
diff --git a/stdnum/gb/upn.py b/stdnum/gb/upn.py
index bfc4f7e..224082c 100644
--- a/stdnum/gb/upn.py
+++ b/stdnum/gb/upn.py
@@ -48,8 +48,8 @@ Traceback (most recent call last):
InvalidComponent: ...
"""
-from stdnum.util import clean
from stdnum.exceptions import *
+from stdnum.util import clean
# The allowed characters in an UPN.
diff --git a/stdnum/gb/vat.py b/stdnum/gb/vat.py
index 192cc79..539e2f9 100644
--- a/stdnum/gb/vat.py
+++ b/stdnum/gb/vat.py
@@ -35,8 +35,8 @@ InvalidChecksum: ...
'980 7806 84'
"""
-from stdnum.util import clean
from stdnum.exceptions import *
+from stdnum.util import clean
def compact(number):
diff --git a/stdnum/is_/kennitala.py b/stdnum/is_/kennitala.py
index 7439fad..e810915 100644
--- a/stdnum/is_/kennitala.py
+++ b/stdnum/is_/kennitala.py
@@ -40,8 +40,8 @@ InvalidComponent: ...
'120174-3399'
"""
-import re
import datetime
+import re
from stdnum.exceptions import *
from stdnum.util import clean
diff --git a/stdnum/it/codicefiscale.py b/stdnum/it/codicefiscale.py
index 0d3a4e3..0e26722 100644
--- a/stdnum/it/codicefiscale.py
+++ b/stdnum/it/codicefiscale.py
@@ -42,8 +42,8 @@ InvalidLength: ...
'H'
"""
-import re
import datetime
+import re
from stdnum.exceptions import *
from stdnum.util import clean
diff --git a/stdnum/nl/onderwijsnummer.py b/stdnum/nl/onderwijsnummer.py
index 0997ada..ed0cd6e 100644
--- a/stdnum/nl/onderwijsnummer.py
+++ b/stdnum/nl/onderwijsnummer.py
@@ -44,7 +44,7 @@ InvalidFormat: ...
"""
from stdnum.exceptions import *
-from stdnum.nl.bsn import compact, checksum
+from stdnum.nl.bsn import checksum, compact
__all__ = ['compact', 'validate', 'is_valid']
diff --git a/stdnum/numdb.py b/stdnum/numdb.py
index e04faa6..40ebdb4 100644
--- a/stdnum/numdb.py
+++ b/stdnum/numdb.py
@@ -84,6 +84,7 @@ True
"""
import re
+
from pkg_resources import resource_stream
_line_re = re.compile(
diff --git a/stdnum/rs/pib.py b/stdnum/rs/pib.py
index 73b46fe..8ba652b 100644
--- a/stdnum/rs/pib.py
+++ b/stdnum/rs/pib.py
@@ -32,8 +32,8 @@ InvalidChecksum: ...
"""
from stdnum.exceptions import *
-from stdnum.util import clean
from stdnum.iso7064 import mod_11_10
+from stdnum.util import clean
def compact(number):
diff --git a/stdnum/sk/rc.py b/stdnum/sk/rc.py
index d0ffa8f..84eb9c9 100644
--- a/stdnum/sk/rc.py
+++ b/stdnum/sk/rc.py
@@ -49,5 +49,5 @@ InvalidLength: ...
# since this number is essentially the same as the Czech counterpart
# (until 1993 the Czech Republic and Slovakia were one country)
-from stdnum.cz.rc import compact, validate, is_valid, format
+from stdnum.cz.rc import compact, format, is_valid, validate
__all__ = ['compact', 'validate', 'is_valid', 'format']
diff --git a/stdnum/us/tin.py b/stdnum/us/tin.py
index edcc7f8..c32c789 100644
--- a/stdnum/us/tin.py
+++ b/stdnum/us/tin.py
@@ -49,7 +49,7 @@ InvalidFormat: ...
"""
from stdnum.exceptions import *
-from stdnum.us import ssn, itin, ein, ptin, atin
+from stdnum.us import atin, ein, itin, ptin, ssn
from stdnum.util import clean
_tin_modules = (ssn, itin, ein, ptin, atin)
https://arthurdejong.org/git/python-stdnum/commit/?id=1c276393d695f969f4600cb3adc49af71168d513
commit 1c276393d695f969f4600cb3adc49af71168d513
Author: Arthur de Jong <arthur@arthurdejong.org>
Date: Sun Sep 10 23:24:08 2017 +0200
Docstring improvements
diff --git a/stdnum/al/nipt.py b/stdnum/al/nipt.py
index 6c7214a..9091ac7 100644
--- a/stdnum/al/nipt.py
+++ b/stdnum/al/nipt.py
@@ -61,8 +61,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length and formatting."""
+ """Check if the number is a valid VAT number. This checks the length and
+ formatting."""
number = compact(number)
if len(number) != 10:
raise InvalidLength()
@@ -72,8 +72,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length and formatting."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ar/cbu.py b/stdnum/ar/cbu.py
index cd753ac..31fe5d8 100644
--- a/stdnum/ar/cbu.py
+++ b/stdnum/ar/cbu.py
@@ -59,7 +59,7 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid CBU."""
+ """Check if the number is a valid CBU."""
number = compact(number)
if len(number) != 22:
raise InvalidLength()
@@ -73,7 +73,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid CBU."""
+ """Check if the number is a valid CBU."""
try:
return bool(validate(number))
except ValidationError:
@@ -81,6 +81,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((number[:8], number[8:]))
diff --git a/stdnum/ar/cuit.py b/stdnum/ar/cuit.py
index fb6bf83..93ff696 100644
--- a/stdnum/ar/cuit.py
+++ b/stdnum/ar/cuit.py
@@ -61,7 +61,7 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid CUIT."""
+ """Check if the number is a valid CUIT."""
number = compact(number)
if len(number) != 11:
raise InvalidLength()
@@ -73,7 +73,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid CUIT."""
+ """Check if the number is a valid CUIT."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/at/businessid.py b/stdnum/at/businessid.py
index 8ce5ab7..20c2a0f 100644
--- a/stdnum/at/businessid.py
+++ b/stdnum/at/businessid.py
@@ -53,8 +53,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid company register
- number. This only checks the formatting."""
+ """Check if the number is a valid company register number. This only
+ checks the formatting."""
number = compact(number)
if not number[-1:].isalpha() or not number[:-1].isdigit():
raise InvalidFormat()
@@ -62,8 +62,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid company register
- number. This only checks the formatting."""
+ """Check if the number is a valid company register number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/at/uid.py b/stdnum/at/uid.py
index a070d5a..e11aa76 100644
--- a/stdnum/at/uid.py
+++ b/stdnum/at/uid.py
@@ -53,8 +53,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if number[:1] != 'U' or not number[1:].isdigit():
raise InvalidFormat()
@@ -66,8 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/au/abn.py b/stdnum/au/abn.py
index ba69557..301eb13 100644
--- a/stdnum/au/abn.py
+++ b/stdnum/au/abn.py
@@ -58,8 +58,8 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid ABN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid ABN. This checks the length, formatting
+ and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -71,8 +71,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ABN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid ABN."""
try:
return bool(validate(number))
except ValidationError:
@@ -80,6 +79,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((number[0:2], number[2:5], number[5:8], number[8:]))
diff --git a/stdnum/au/acn.py b/stdnum/au/acn.py
index ed99d3d..ac78695 100644
--- a/stdnum/au/acn.py
+++ b/stdnum/au/acn.py
@@ -57,8 +57,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid ACN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid ACN. This checks the length, formatting
+ and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -70,8 +70,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ACN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid ACN."""
try:
return bool(validate(number))
except ValidationError:
@@ -79,7 +78,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((number[0:3], number[3:6], number[6:]))
diff --git a/stdnum/au/tfn.py b/stdnum/au/tfn.py
index f4c1ab4..5cee2a8 100644
--- a/stdnum/au/tfn.py
+++ b/stdnum/au/tfn.py
@@ -59,8 +59,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid TFN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid TFN. This checks the length, formatting
+ and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -72,8 +72,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid TFN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid TFN."""
try:
return bool(validate(number))
except ValidationError:
@@ -81,6 +80,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((number[0:3], number[3:6], number[6:]))
diff --git a/stdnum/be/vat.py b/stdnum/be/vat.py
index 39a3335..5e4c36d 100644
--- a/stdnum/be/vat.py
+++ b/stdnum/be/vat.py
@@ -58,8 +58,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -71,8 +71,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/bg/egn.py b/stdnum/bg/egn.py
index 5aa007b..959e309 100644
--- a/stdnum/bg/egn.py
+++ b/stdnum/bg/egn.py
@@ -78,9 +78,8 @@ def get_birth_date(number):
def validate(number):
- """Checks to see if the number provided is a valid national
- identification number. This checks the length, formatting, embedded
- date and check digit."""
+ """Check if the number is a valid national identification number. This
+ checks the length, formatting, embedded date and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -96,9 +95,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid national
- identification number. This checks the length, formatting, embedded
- date and check digit."""
+ """Check if the number is a valid national identification number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/bg/pnf.py b/stdnum/bg/pnf.py
index 0f2eb64..726159f 100644
--- a/stdnum/bg/pnf.py
+++ b/stdnum/bg/pnf.py
@@ -53,9 +53,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid national
- identification number. This checks the length, formatting, embedded
- date and check digit."""
+ """Check if the number is a valid national identification number. This
+ checks the length, formatting, embedded date and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -67,9 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid national
- identification number. This checks the length, formatting, embedded
- date and check digit."""
+ """Check if the number is a valid national identification number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/bg/vat.py b/stdnum/bg/vat.py
index 757c48a..808d1de 100644
--- a/stdnum/bg/vat.py
+++ b/stdnum/bg/vat.py
@@ -65,8 +65,8 @@ def calc_check_digit_other(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -85,8 +85,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/br/cnpj.py b/stdnum/br/cnpj.py
index 3d34ed6..c153b8c 100644
--- a/stdnum/br/cnpj.py
+++ b/stdnum/br/cnpj.py
@@ -59,8 +59,8 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid CNPJ. This checks the
- length and whether the check digits are correct."""
+ """Check if the number is a valid CNPJ. This checks the length and
+ whether the check digits are correct."""
number = compact(number)
if not number.isdigit() or int(number) <= 0:
raise InvalidFormat()
@@ -72,8 +72,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid CNPJ. This checks the
- length and whether the check digits are correct."""
+ """Check if the number is a valid CNPJ."""
try:
return bool(validate(number))
except ValidationError:
@@ -81,6 +80,7 @@ def is_valid(number):
def format(number):
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return (number[0:2] + '.' + number[2:5] + '.' + number[5:8] + '/' +
number[8:12] + '-' + number[12:])
diff --git a/stdnum/br/cpf.py b/stdnum/br/cpf.py
index b8b4f6e..5287d64 100644
--- a/stdnum/br/cpf.py
+++ b/stdnum/br/cpf.py
@@ -62,8 +62,8 @@ def _calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid CPF. This checks
- the length and whether the check digit is correct."""
+ """Check if the number is a valid CPF. This checks the length and whether
+ the check digit is correct."""
number = compact(number)
if not number.isdigit() or int(number) <= 0:
raise InvalidFormat()
@@ -75,8 +75,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid CPF. This checks
- the length and whether the check digit is correct."""
+ """Check if the number is a valid CPF."""
try:
return bool(validate(number))
except ValidationError:
@@ -84,6 +83,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:3] + '.' + number[3:6] + '.' + number[6:-2] + '-' +
number[-2:]
diff --git a/stdnum/ca/bn.py b/stdnum/ca/bn.py
index 37d44d9..d55f34a 100644
--- a/stdnum/ca/bn.py
+++ b/stdnum/ca/bn.py
@@ -55,8 +55,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid BN or BN15. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid BN or BN15. This checks the length,
+ formatting and check digit."""
number = compact(number)
if len(number) not in (9, 15):
raise InvalidLength()
@@ -72,8 +72,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid BN or BN15. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid BN or BN15."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ca/sin.py b/stdnum/ca/sin.py
index 59e8713..05508b5 100644
--- a/stdnum/ca/sin.py
+++ b/stdnum/ca/sin.py
@@ -55,8 +55,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid SIN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid SIN. This checks the length, formatting
+ and check digit."""
number = compact(number)
if len(number) != 9:
raise InvalidLength()
@@ -66,8 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid SIN. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid SIN."""
try:
return bool(validate(number))
except ValidationError:
@@ -75,6 +74,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return '-'.join((number[0:3], number[3:6], number[6:]))
diff --git a/stdnum/ch/ssn.py b/stdnum/ch/ssn.py
index 57e88cf..a59dc4f 100644
--- a/stdnum/ch/ssn.py
+++ b/stdnum/ch/ssn.py
@@ -58,14 +58,13 @@ def compact(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return '.'.join((number[:3], number[3:7], number[7:11], number[11:]))
def validate(number):
- """Checks to see if the number provided is a valid Swiss
- Sozialversicherungsnummer."""
+ """Check if the number is a valid Swiss Sozialversicherungsnummer."""
number = compact(number)
if len(number) != 13:
raise InvalidLength()
@@ -75,8 +74,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid
- Sozialversicherungsnummer."""
+ """Check if the number is a valid Swiss Sozialversicherungsnummer."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ch/uid.py b/stdnum/ch/uid.py
index 62800bc..461715d 100644
--- a/stdnum/ch/uid.py
+++ b/stdnum/ch/uid.py
@@ -61,8 +61,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid UID. This checks the length, formatting
+ and check digit."""
number = compact(number)
if len(number) != 12:
raise InvalidLength()
@@ -76,8 +76,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid UID."""
try:
return bool(validate(number))
except ValidationError:
@@ -85,7 +84,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:3] + '-' + '.'.join(
number[i:i + 3] for i in range(3, len(number), 3))
diff --git a/stdnum/ch/vat.py b/stdnum/ch/vat.py
index 6e32ea7..cc8f2b7 100644
--- a/stdnum/ch/vat.py
+++ b/stdnum/ch/vat.py
@@ -54,8 +54,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if len(number) not in (15, 16):
raise InvalidLength()
@@ -66,8 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
@@ -75,6 +74,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return uid.format(number[:12]) + ' ' + number[12:]
diff --git a/stdnum/cl/rut.py b/stdnum/cl/rut.py
index ba27fa8..58b93b3 100644
--- a/stdnum/cl/rut.py
+++ b/stdnum/cl/rut.py
@@ -63,8 +63,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid RUT. This checks the length, formatting
+ and check digit."""
number = compact(number)
if len(number) not in (8, 9):
raise InvalidLength()
@@ -76,8 +76,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid RUT."""
try:
return bool(validate(number))
except ValidationError:
@@ -85,7 +84,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return (number[:-7] + '.' + number[-7:-4] + '.' +
number[-4:-1] + '-' + number[-1])
diff --git a/stdnum/cn/ric.py b/stdnum/cn/ric.py
index 800a94b..316e97d 100644
--- a/stdnum/cn/ric.py
+++ b/stdnum/cn/ric.py
@@ -71,13 +71,15 @@ def get_birth_place(number):
def calc_check_digit(number):
+ """Calculate the check digit. The number passed should have the check
+ digit included."""
checksum = (1 - 2 * int(number[:-1], 13)) % 11
return 'X' if checksum == 10 else str(checksum)
def validate(number):
- """Checks to see if the number provided is a valid RIC numbers. This
- checks the length, formatting and birth date and place."""
+ """Check if the number is a valid RIC number. This checks the length,
+ formatting and birth date and place."""
number = compact(number)
if len(number) != 18:
raise InvalidLength()
@@ -93,8 +95,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid RIC numbers. This
- checks the length, formatting and birth date and place."""
+ """Check if the number is a valid RIC number."""
try:
return bool(validate(number))
except ValidationError:
@@ -102,5 +103,5 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
return compact(number)
diff --git a/stdnum/co/nit.py b/stdnum/co/nit.py
index 6cb2fc9..fe3dd48 100644
--- a/stdnum/co/nit.py
+++ b/stdnum/co/nit.py
@@ -54,8 +54,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid NIT. This checks the length, formatting
+ and check digit."""
number = compact(number)
if not 8 <= len(number) <= 16:
raise InvalidLength()
@@ -67,8 +67,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid NIT."""
try:
return bool(validate(number))
except ValidationError:
@@ -76,7 +75,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return '.'.join(
number[i - 3:i] for i in reversed(range(-1, -len(number), -3))
diff --git a/stdnum/cusip.py b/stdnum/cusip.py
index 9fa6d90..ae69e6a 100644
--- a/stdnum/cusip.py
+++ b/stdnum/cusip.py
@@ -62,8 +62,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
number = compact(number)
if not all(x in _alphabet for x in number):
raise InvalidFormat()
@@ -75,8 +75,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/cy/vat.py b/stdnum/cy/vat.py
index 7ab320e..df3674d 100644
--- a/stdnum/cy/vat.py
+++ b/stdnum/cy/vat.py
@@ -60,8 +60,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number[:-1].isdigit():
raise InvalidFormat()
@@ -75,8 +75,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/cz/dic.py b/stdnum/cz/dic.py
index df507ac..66ece03 100644
--- a/stdnum/cz/dic.py
+++ b/stdnum/cz/dic.py
@@ -69,8 +69,8 @@ def calc_check_digit_special(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -93,8 +93,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/cz/rc.py b/stdnum/cz/rc.py
index d8b1c4d..603f7ee 100644
--- a/stdnum/cz/rc.py
+++ b/stdnum/cz/rc.py
@@ -81,8 +81,8 @@ def get_birth_date(number):
def validate(number):
- """Checks to see if the number provided is a valid birth number. This
- checks the length, formatting, embedded date and check digit."""
+ """Check if the number is a valid birth number. This checks the length,
+ formatting, embedded date and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -103,8 +103,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid birth number. This
- checks the length, formatting, embedded date and check digit."""
+ """Check if the number is a valid birth number."""
try:
return bool(validate(number))
except ValidationError:
@@ -112,6 +111,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:6] + '/' + number[6:]
diff --git a/stdnum/damm.py b/stdnum/damm.py
index cf8a2cd..b37c08c 100644
--- a/stdnum/damm.py
+++ b/stdnum/damm.py
@@ -67,7 +67,7 @@ def checksum(number, table=None):
def validate(number, table=None):
- """Checks to see if the number provided passes the Damm algorithm."""
+ """Check if the number provided passes the Damm algorithm."""
if not bool(number):
raise InvalidFormat()
try:
@@ -80,7 +80,7 @@ def validate(number, table=None):
def is_valid(number, table=None):
- """Checks to see if the number provided passes the Damm algorithm."""
+ """Check if the number provided passes the Damm algorithm."""
try:
return bool(validate(number, table=table))
except ValidationError:
@@ -88,6 +88,6 @@ def is_valid(number, table=None):
def calc_check_digit(number, table=None):
- """With the provided number, calculate the extra digit that should be
- appended to make it pass the Damm check."""
+ """Calculate the extra digit that should be appended to the number to
+ make it a valid number."""
return str(checksum(number, table=table))
diff --git a/stdnum/de/idnr.py b/stdnum/de/idnr.py
index a9952fd..c2f45c5 100644
--- a/stdnum/de/idnr.py
+++ b/stdnum/de/idnr.py
@@ -59,8 +59,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid tax identification
- number. This checks the length, formatting and check digit."""
+ """Check if the number provided is a valid tax identification number.
+ This checks the length, formatting and check digit."""
number = compact(number)
if len(number) != 11:
raise InvalidLength()
@@ -80,8 +80,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid tax identification
- number. This checks the length, formatting and check digit."""
+ """Check if the number provided is a valid tax identification number.
+ This checks the length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
@@ -89,6 +89,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((number[:2], number[2:5], number[5:8], number[8:]))
diff --git a/stdnum/de/vat.py b/stdnum/de/vat.py
index b36259b..3581e41 100644
--- a/stdnum/de/vat.py
+++ b/stdnum/de/vat.py
@@ -47,8 +47,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number.isdigit() or number[0] == '0':
raise InvalidFormat()
@@ -59,8 +59,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/de/wkn.py b/stdnum/de/wkn.py
index 8cde237..f2242bd 100644
--- a/stdnum/de/wkn.py
+++ b/stdnum/de/wkn.py
@@ -49,8 +49,8 @@ _alphabet = '0123456789ABCDEFGH JKLMN PQRSTUVWXYZ'
def validate(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
number = compact(number)
if not all(x in _alphabet for x in number):
raise InvalidFormat()
@@ -60,8 +60,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/dk/cpr.py b/stdnum/dk/cpr.py
index 2566c64..ead77df 100644
--- a/stdnum/dk/cpr.py
+++ b/stdnum/dk/cpr.py
@@ -89,8 +89,8 @@ def get_birth_date(number):
def validate(number):
- """Checks to see if the number provided is a valid CPR number. This
- checks the length, formatting, embedded date and check digit."""
+ """Check if the number provided is a valid CPR number. This checks the
+ length, formatting, embedded date and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -103,8 +103,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid CPR number. This
- checks the length, formatting, embedded date and check digit."""
+ """Check if the number provided is a valid CPR number. This checks the
+ length, formatting, embedded date and check digit."""
try:
return bool(validate(number))
except ValidationError:
@@ -112,6 +112,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return '-'.join((number[:6], number[6:]))
diff --git a/stdnum/dk/cvr.py b/stdnum/dk/cvr.py
index 3088c40..808f1c9 100644
--- a/stdnum/dk/cvr.py
+++ b/stdnum/dk/cvr.py
@@ -50,8 +50,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number.isdigit() or number[0] == '0':
raise InvalidFormat()
@@ -63,8 +63,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/do/cedula.py b/stdnum/do/cedula.py
index 720a691..cd7b81f 100644
--- a/stdnum/do/cedula.py
+++ b/stdnum/do/cedula.py
@@ -131,7 +131,7 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid cedula."""
+ """Check if the number provided is a valid cedula."""
number = compact(number)
if len(number) != 11:
raise InvalidLength()
@@ -143,7 +143,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid cedula."""
+ """Check if the number provided is a valid cedula."""
try:
return bool(validate(number))
except ValidationError:
@@ -151,6 +151,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return '-'.join((number[:3], number[3:-1], number[-1]))
diff --git a/stdnum/do/rnc.py b/stdnum/do/rnc.py
index dce10e6..a20ce67 100644
--- a/stdnum/do/rnc.py
+++ b/stdnum/do/rnc.py
@@ -54,7 +54,7 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid RNC."""
+ """Check if the number provided is a valid RNC."""
number = compact(number)
if len(number) != 9:
raise InvalidLength()
@@ -66,7 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid RNC."""
+ """Check if the number provided is a valid RNC."""
try:
return bool(validate(number))
except ValidationError:
@@ -74,6 +74,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return '-'.join((number[:1], number[1:3], number[3:-1], number[-1]))
diff --git a/stdnum/ean.py b/stdnum/ean.py
index c237f2e..36f825a 100644
--- a/stdnum/ean.py
+++ b/stdnum/ean.py
@@ -46,9 +46,9 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid EAN-13. This checks
- the length and the check bit but does not check whether a known GS1
- Prefix and company identifier are referenced."""
+ """Check if the number provided is a valid EAN-13. This checks the length
+ and the check bit but does not check whether a known GS1 Prefix and
+ company identifier are referenced."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -60,9 +60,9 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid EAN-13. This checks
- the length and the check bit but does not check whether a known GS1
- Prefix and company identifier are referenced."""
+ """Check if the number provided is a valid EAN-13. This checks the length
+ and the check bit but does not check whether a known GS1 Prefix and
+ company identifier are referenced."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ec/ci.py b/stdnum/ec/ci.py
index 9af837d..cb7a882 100644
--- a/stdnum/ec/ci.py
+++ b/stdnum/ec/ci.py
@@ -53,8 +53,8 @@ def _checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid CI number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid CI number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if len(number) != 10:
raise InvalidLength()
@@ -70,8 +70,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid CI number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid CI number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ec/ruc.py b/stdnum/ec/ruc.py
index 1312f77..8a4b54a 100644
--- a/stdnum/ec/ruc.py
+++ b/stdnum/ec/ruc.py
@@ -53,8 +53,8 @@ def _checksum(number, weights):
def validate(number):
- """Checks to see if the number provided is a valid RUC number. This
- checks the length, formatting, check digit and check sum."""
+ """Check if the number provided is a valid RUC number. This checks the
+ length, formatting, check digit and check sum."""
number = compact(number)
if len(number) != 13:
raise InvalidLength()
@@ -85,8 +85,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid RUC number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid RUC number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ee/ik.py b/stdnum/ee/ik.py
index a22c7a2..bdc93ff 100644
--- a/stdnum/ee/ik.py
+++ b/stdnum/ee/ik.py
@@ -91,7 +91,7 @@ def calc_check_digit(number):
def validate(number):
- """Checks if the number provided is valid. This checks the length,
+ """Check if the number provided is valid. This checks the length,
formatting, embedded date and check digit."""
number = compact(number)
if not number.isdigit():
@@ -105,7 +105,7 @@ def validate(number):
def is_valid(number):
- """Checks if the number provided is valid. This checks the length,
+ """Check if the number provided is valid. This checks the length,
formatting, embedded date and check digit."""
try:
return bool(validate(number))
diff --git a/stdnum/ee/kmkr.py b/stdnum/ee/kmkr.py
index 4b098c4..a5762e5 100644
--- a/stdnum/ee/kmkr.py
+++ b/stdnum/ee/kmkr.py
@@ -50,8 +50,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -63,8 +63,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ee/registrikood.py b/stdnum/ee/registrikood.py
index 778fb9b..d5d379d 100644
--- a/stdnum/ee/registrikood.py
+++ b/stdnum/ee/registrikood.py
@@ -59,8 +59,8 @@ def compact(number):
def validate(number):
- """Checks if the number provided is valid. This checks the length,
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -74,10 +74,8 @@ def validate(number):
def is_valid(number):
- """
- Checks if the number provided is valid. This checks the length,
- and check digit.
- """
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/ccc.py b/stdnum/es/ccc.py
index 3800bb3..69a4105 100644
--- a/stdnum/es/ccc.py
+++ b/stdnum/es/ccc.py
@@ -73,7 +73,7 @@ def compact(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join([
number[0:4],
@@ -99,7 +99,7 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid CCC."""
+ """Check if the number provided is a valid CCC."""
number = compact(number)
if len(number) != 20:
raise InvalidLength()
@@ -111,7 +111,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid CCC."""
+ """Check if the number provided is a valid CCC."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/cif.py b/stdnum/es/cif.py
index eeb0e72..0c87711 100644
--- a/stdnum/es/cif.py
+++ b/stdnum/es/cif.py
@@ -65,8 +65,8 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid DNI number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid DNI number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number[1:-1].isdigit():
raise InvalidFormat()
@@ -92,8 +92,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid DNI number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid DNI number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/cups.py b/stdnum/es/cups.py
index 5aa847a..a2011e2 100644
--- a/stdnum/es/cups.py
+++ b/stdnum/es/cups.py
@@ -64,7 +64,7 @@ def compact(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((
number[:2],
@@ -85,8 +85,8 @@ def calc_check_digits(number):
def validate(number):
- """Check to see if the number provided is a valid CUPS. This checks
- length, formatting and check digits."""
+ """Check if the number provided is a valid CUPS. This checks length,
+ formatting and check digits."""
number = compact(number)
if len(number) not in (20, 22):
raise InvalidLength()
@@ -106,7 +106,7 @@ def validate(number):
def is_valid(number):
- """Check to see if the number provided is a valid CUPS."""
+ """Check if the number provided is a valid CUPS."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/dni.py b/stdnum/es/dni.py
index 18d0954..9b529ef 100644
--- a/stdnum/es/dni.py
+++ b/stdnum/es/dni.py
@@ -55,8 +55,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid DNI number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid DNI number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number[:-1].isdigit():
raise InvalidFormat()
@@ -68,8 +68,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid DNI number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid DNI number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/iban.py b/stdnum/es/iban.py
index 5d25774..9c31296 100644
--- a/stdnum/es/iban.py
+++ b/stdnum/es/iban.py
@@ -65,14 +65,14 @@ def to_ccc(number):
def validate(number):
- """Checks to see if the number provided is a valid Spanish IBAN."""
+ """Check if the number provided is a valid Spanish IBAN."""
number = iban.validate(number, check_country=False)
ccc.validate(to_ccc(number))
return number
def is_valid(number):
- """Checks to see if the number provided is a valid Spanish IBAN."""
+ """Check if the number provided is a valid Spanish IBAN."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/nie.py b/stdnum/es/nie.py
index 01d218d..91c5918 100644
--- a/stdnum/es/nie.py
+++ b/stdnum/es/nie.py
@@ -56,8 +56,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid NIE. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid NIE. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number[1:-1].isdigit() or number[:1] not in 'XYZ':
raise InvalidFormat()
@@ -69,8 +69,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid NIE. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid NIE. This checks the length,
+ formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/nif.py b/stdnum/es/nif.py
index 7cd689e..b392a3a 100644
--- a/stdnum/es/nif.py
+++ b/stdnum/es/nif.py
@@ -57,8 +57,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number[1:-1].isdigit():
raise InvalidFormat()
@@ -77,8 +77,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/es/referenciacatastral.py b/stdnum/es/referenciacatastral.py
index b9882cf..8b32082 100644
--- a/stdnum/es/referenciacatastral.py
+++ b/stdnum/es/referenciacatastral.py
@@ -68,7 +68,7 @@ def compact(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join([
number[:7],
@@ -106,8 +106,8 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid Cadastral Reference.
- This checks the length, formatting and check digits."""
+ """Check if the number is a valid Cadastral Reference. This checks the
+ length, formatting and check digits."""
number = compact(number)
n = _force_unicode(number)
if not all(c in alphabet for c in n):
@@ -120,7 +120,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid Cadastral Reference."""
+ """Check if the number is a valid Cadastral Reference."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/eu/at_02.py b/stdnum/eu/at_02.py
index ca5973e..8852cd1 100644
--- a/stdnum/eu/at_02.py
+++ b/stdnum/eu/at_02.py
@@ -17,7 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
-""" SEPA Identifier of the Creditor (AT-02)
+"""SEPA Identifier of the Creditor (AT-02).
This identifier is indicated in the ISO 20022 data element `Creditor Scheme
Identification`. The creditor can be a legal entity, or an association that
@@ -60,7 +60,7 @@ def _to_base10(number):
def validate(number):
- """Checks to see if the number provided is a valid AT-02."""
+ """Check if the number provided is a valid AT-02."""
number = compact(number)
try:
test_number = _to_base10(number)
@@ -72,7 +72,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid AT-02."""
+ """Check if the number provided is a valid AT-02."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/eu/eic.py b/stdnum/eu/eic.py
index 88d28e0..e6d9419 100644
--- a/stdnum/eu/eic.py
+++ b/stdnum/eu/eic.py
@@ -65,8 +65,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length,
- format and check digit."""
+ """Check if the number is valid. This checks the length, format and check
+ digit."""
number = compact(number)
if not all(x in _alphabet for x in number):
raise InvalidFormat()
@@ -80,8 +80,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length,
- format and check digit."""
+ """Check if the number is valid. This checks the length, format and check
+ digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/eu/nace.py b/stdnum/eu/nace.py
index 344629c..64743b0 100644
--- a/stdnum/eu/nace.py
+++ b/stdnum/eu/nace.py
@@ -80,8 +80,8 @@ def label(number):
def validate(number):
- """Checks to see if the number provided is a valid NACE. This checks the
- format and searches the registry to see if it exists."""
+ """Check if the number is a valid NACE. This checks the format and
+ searches the registry to see if it exists."""
number = compact(number)
if len(number) > 4:
raise InvalidLength()
@@ -96,8 +96,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid NACE. This checks the
- format and searches the registry to see if it exists."""
+ """Check if the number is a valid NACE. This checks the format and
+ searches the registry to see if it exists."""
try:
return bool(validate(number))
except ValidationError:
@@ -105,5 +105,5 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
return '.'.join((number[:2], number[2:])).strip('.')
diff --git a/stdnum/eu/vat.py b/stdnum/eu/vat.py
index 3604aba..3a6a2eb 100644
--- a/stdnum/eu/vat.py
+++ b/stdnum/eu/vat.py
@@ -84,8 +84,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- performs the country-specific check for the number."""
+ """Check if the number is a valid VAT number. This performs the
+ country-specific check for the number."""
number = clean(number, '').upper().strip()
module = _get_cc_module(number[:2])
if not module:
@@ -94,8 +94,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- performs the country-specific check for the number."""
+ """Check if the number is a valid VAT number. This performs the
+ country-specific check for the number."""
try:
return bool(validate(number))
except ValidationError:
@@ -103,10 +103,10 @@ def is_valid(number):
def guess_country(number):
- """Guess the country code based on the provided number. This checks the
- provided number against each of the validation routines and returns
- the list of countries for which it is valid. This returns lower case
- codes and returns gr (not el) for Greece."""
+ """Guess the country code based on the number. This checks the number
+ against each of the validation routines and returns the list of countries
+ for which it is valid. This returns lower case codes and returns gr (not
+ el) for Greece."""
return [cc
for cc in country_codes
if _get_cc_module(cc).is_valid(number)]
@@ -123,10 +123,10 @@ def _get_client(): # pragma: no cover (no tests for this
function)
def check_vies(number): # pragma: no cover (no tests for this function)
- """Queries the online European Commission VAT Information Exchange
- System (VIES) for validity of the provided number. Note that the
- service has usage limitations (see the VIES website for details).
- This returns a dict-like object."""
+ """Query the online European Commission VAT Information Exchange System
+ (VIES) for validity of the provided number. Note that the service has
+ usage limitations (see the VIES website for details). This returns a
+ dict-like object."""
# this function isn't automatically tested because it would require
# network access for the tests and unnecessarily load the VIES website
number = compact(number)
@@ -134,7 +134,7 @@ def check_vies(number): # pragma: no cover (no tests for
this function)
def check_vies_approx(number, requester): # pragma: no cover
- """Queries the online European Commission VAT Information Exchange System
+ """Query the online European Commission VAT Information Exchange System
(VIES) for validity of the provided number, providing a validity
certificate as proof. You will need to give your own VAT number for this
to work. Note that the service has usage limitations (see the VIES
diff --git a/stdnum/fi/alv.py b/stdnum/fi/alv.py
index 832742c..9a0820c 100644
--- a/stdnum/fi/alv.py
+++ b/stdnum/fi/alv.py
@@ -50,8 +50,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -63,8 +63,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/fi/associationid.py b/stdnum/fi/associationid.py
index 4efed2b..be2fd13 100644
--- a/stdnum/fi/associationid.py
+++ b/stdnum/fi/associationid.py
@@ -60,12 +60,8 @@ def compact(number):
def validate(number):
- """
- Validate the format of a Finnish association register number.
-
- First strip all separators and spaces from the number and then checks
- that it has a correct length and is only numeric.
- """
+ """Check if the number is a valid Finnish association register number.
+ This checks the length and format."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -77,8 +73,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid association register
- number. This checks that the format is correct."""
+ """Check if the number is a valid association register number."""
try:
return bool(validate(number))
except ValidationError:
@@ -86,7 +81,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
if len(number) <= 3:
return number
diff --git a/stdnum/fi/hetu.py b/stdnum/fi/hetu.py
index 69b543e..580fe6c 100644
--- a/stdnum/fi/hetu.py
+++ b/stdnum/fi/hetu.py
@@ -72,9 +72,8 @@ def _calc_checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid HETU. It checks the
- format, whether a valid date is given and whether the check digit is
- correct."""
+ """Check if the number is a valid HETU. It checks the format, whether a
+ valid date is given and whether the check digit is correct."""
number = compact(number)
match = _hetu_re.search(number)
if not match:
@@ -99,9 +98,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid HETU. It checks the
- format, whether a valid date is given and whether the check digit is
- correct."""
+ """Check if the number is a valid HETU."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/fi/veronumero.py b/stdnum/fi/veronumero.py
index 6bee0b6..78023e1 100644
--- a/stdnum/fi/veronumero.py
+++ b/stdnum/fi/veronumero.py
@@ -54,8 +54,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid tax number. This
- checks the length and formatting."""
+ """Check if the number is a valid tax number. This checks the length and
+ formatting."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -66,8 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid tax number. This
- checks the length and formatting."""
+ """Check if the number is a valid tax number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/fi/ytunnus.py b/stdnum/fi/ytunnus.py
index 10114eb..2f38241 100644
--- a/stdnum/fi/ytunnus.py
+++ b/stdnum/fi/ytunnus.py
@@ -44,14 +44,13 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid business identifier.
- This checks the length, formatting and check digit."""
+ """Check if the number is a valid business identifier. This checks the
+ length, formatting and check digit."""
return alv.validate(number)
def is_valid(number):
- """Checks to see if the number provided is a valid business identifier.
- This checks the length, formatting and check digit."""
+ """Check if the number is a valid business identifier."""
try:
return bool(validate(number))
except ValidationError:
@@ -59,6 +58,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:7] + '-' + number[7:]
diff --git a/stdnum/fr/nif.py b/stdnum/fr/nif.py
index 4771562..e3eb256 100644
--- a/stdnum/fr/nif.py
+++ b/stdnum/fr/nif.py
@@ -51,7 +51,7 @@ def compact(number):
def validate(number):
- """Checks the length to see if the number provided is valid."""
+ """Check if the number provided is a valid NIF."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -61,7 +61,7 @@ def validate(number):
def is_valid(number):
- """Checks the length to see if the number provided is valid."""
+ """Check if the number provided is a valid NIF."""
try:
return bool(validate(number))
except ValidationError:
@@ -69,7 +69,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((number[:2], number[2:4], number[4:7],
number[7:10], number[10:]))
diff --git a/stdnum/fr/nir.py b/stdnum/fr/nir.py
index c9381b2..bbd6bc6 100644
--- a/stdnum/fr/nir.py
+++ b/stdnum/fr/nir.py
@@ -74,7 +74,7 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length
+ """Check if the number provided is valid. This checks the length
and check digits."""
number = compact(number)
if not (number.isdigit() or (
@@ -89,8 +89,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digits."""
+ """Check if the number provided is valid."""
try:
return bool(validate(number))
except ValidationError:
@@ -98,7 +97,7 @@ def is_valid(number):
def format(number, separator=' '):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return separator.join((number[:1], number[1:3], number[3:5], number[5:7],
number[7:10], number[10:13], number[13:]))
diff --git a/stdnum/fr/siren.py b/stdnum/fr/siren.py
index ff06b69..ce94841 100644
--- a/stdnum/fr/siren.py
+++ b/stdnum/fr/siren.py
@@ -54,8 +54,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid SIREN. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -66,8 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid SIREN."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/fr/siret.py b/stdnum/fr/siret.py
index 22efe20..5532147 100644
--- a/stdnum/fr/siret.py
+++ b/stdnum/fr/siret.py
@@ -55,8 +55,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid SIRET. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -68,8 +68,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid SIRET."""
try:
return bool(validate(number))
except ValidationError:
@@ -77,7 +76,7 @@ def is_valid(number):
def to_siren(number):
- """Return SIREN number from the given SIRET number.
+ """Convert the SIRET number to a SIREN number.
The SIREN number is the 9 first digits of the SIRET number.
"""
@@ -92,7 +91,7 @@ def to_siren(number):
def to_tva(number):
- """Return TVA number from the given SIRET number.
+ """Convert the SIRET number to a TVA number.
The TVA number is built from the SIREN number, prepended by two extra
error checking digits.
@@ -101,6 +100,6 @@ def to_tva(number):
def format(number, separator=' '):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return separator.join((number[0:3], number[3:6], number[6:9], number[9:]))
diff --git a/stdnum/fr/tva.py b/stdnum/fr/tva.py
index bb46fed..896d86f 100644
--- a/stdnum/fr/tva.py
+++ b/stdnum/fr/tva.py
@@ -62,8 +62,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not all(x in _alphabet for x in number[:2]):
raise InvalidFormat()
@@ -94,8 +94,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/gb/nhs.py b/stdnum/gb/nhs.py
index 286d41d..137d7b7 100644
--- a/stdnum/gb/nhs.py
+++ b/stdnum/gb/nhs.py
@@ -58,8 +58,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number is valid. This checks the length and check
+ digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -71,8 +71,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number is valid."""
try:
return bool(validate(number))
except ValidationError:
@@ -80,6 +79,6 @@ def is_valid(number):
def format(number, separator=' '):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return separator.join((number[0:3], number[3:6], number[6:]))
diff --git a/stdnum/gb/sedol.py b/stdnum/gb/sedol.py
index ad768ca..cc1ac7d 100644
--- a/stdnum/gb/sedol.py
+++ b/stdnum/gb/sedol.py
@@ -55,8 +55,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number is valid. This checks the length and check
+ digit."""
number = compact(number)
if not all(x in _alphabet for x in number):
raise InvalidFormat()
@@ -72,8 +72,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number is valid."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/gb/upn.py b/stdnum/gb/upn.py
index 0c65371..bfc4f7e 100644
--- a/stdnum/gb/upn.py
+++ b/stdnum/gb/upn.py
@@ -86,8 +86,8 @@ def calc_check_digit(number):
def validate(number):
- """Check to see if the number provided is a valid UPN. This checks
- length, formatting and check digits."""
+ """Check if the number is a valid UPN. This checks length, formatting and
+ check digits."""
number = compact(number)
if len(number) != 13:
raise InvalidLength()
@@ -101,8 +101,7 @@ def validate(number):
def is_valid(number):
- """Check to see if the number provided is a valid UPN. This checks
- length, formatting and check digits."""
+ """Check if the number is a valid UPN."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/gb/vat.py b/stdnum/gb/vat.py
index a4f5174..192cc79 100644
--- a/stdnum/gb/vat.py
+++ b/stdnum/gb/vat.py
@@ -56,8 +56,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if len(number) == 5:
if not number[2:].isdigit():
@@ -101,8 +101,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
@@ -110,7 +109,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
if len(number) == 5:
# government department or health authority
diff --git a/stdnum/gr/vat.py b/stdnum/gr/vat.py
index 3510a35..0de5cc5 100644
--- a/stdnum/gr/vat.py
+++ b/stdnum/gr/vat.py
@@ -57,8 +57,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -70,8 +70,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/grid.py b/stdnum/grid.py
index b128161..cb94879 100644
--- a/stdnum/grid.py
+++ b/stdnum/grid.py
@@ -51,7 +51,7 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid GRid."""
+ """Check if the number is a valid GRid."""
from stdnum.iso7064 import mod_37_36
number = compact(number)
if len(number) != 18:
@@ -60,7 +60,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid GRid."""
+ """Check if the number is a valid GRid."""
try:
return bool(validate(number))
except ValidationError:
@@ -68,7 +68,7 @@ def is_valid(number):
def format(number, separator='-'):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
number = (number[0:2], number[2:7], number[7:17], number[17:])
return separator.join(x for x in number if x)
diff --git a/stdnum/hr/oib.py b/stdnum/hr/oib.py
index c78dede..9c21e15 100644
--- a/stdnum/hr/oib.py
+++ b/stdnum/hr/oib.py
@@ -47,8 +47,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid OIB number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid OIB number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -59,8 +59,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid OIB number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid OIB number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/hu/anum.py b/stdnum/hu/anum.py
index 5504f46..e35fe8b 100644
--- a/stdnum/hu/anum.py
+++ b/stdnum/hu/anum.py
@@ -51,8 +51,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -64,8 +64,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/iban.py b/stdnum/iban.py
index 5908a71..61d5eb8 100644
--- a/stdnum/iban.py
+++ b/stdnum/iban.py
@@ -98,8 +98,8 @@ def _get_cc_module(cc):
def validate(number, check_country=True):
- """Checks to see if the number provided is a valid IBAN. The country-
- specific check can be disabled with the check_country argument."""
+ """Check if the number provided is a valid IBAN. The country-specific
+ check can be disabled with the check_country argument."""
number = compact(number)
# ensure that checksum is valid
mod_97_10.validate(number[4:] + number[:4])
@@ -119,7 +119,7 @@ def validate(number, check_country=True):
def is_valid(number, check_country=True):
- """Checks to see if the number provided is a valid IBAN."""
+ """Check if the number provided is a valid IBAN."""
try:
return bool(validate(number, check_country=check_country))
except ValidationError:
diff --git a/stdnum/ie/pps.py b/stdnum/ie/pps.py
index 6957381..e64514c 100644
--- a/stdnum/ie/pps.py
+++ b/stdnum/ie/pps.py
@@ -66,8 +66,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid PPS number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid PPS number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not pps_re.match(number):
raise InvalidFormat()
@@ -83,8 +83,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid PPS number. This
- checks the length, formatting and check digit."""
+ """Check if the number provided is a valid PPS number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ie/vat.py b/stdnum/ie/vat.py
index 215480a..fa5bd4a 100644
--- a/stdnum/ie/vat.py
+++ b/stdnum/ie/vat.py
@@ -67,8 +67,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number[:1].isdigit() or not number[2:7].isdigit():
raise InvalidFormat()
@@ -90,8 +90,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length, formatting and check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/imei.py b/stdnum/imei.py
index f030071..a46a992 100644
--- a/stdnum/imei.py
+++ b/stdnum/imei.py
@@ -58,8 +58,7 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid IMEI (or IMEISV)
- number."""
+ """Check if the number provided is a valid IMEI (or IMEISV) number."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -73,7 +72,7 @@ def validate(number):
def imei_type(number):
- """Check the passed number and returns 'IMEI', 'IMEISV' or None (for
+ """Check the passed number and return 'IMEI', 'IMEISV' or None (for
invalid) for checking the type of number passed."""
try:
number = validate(number)
@@ -86,8 +85,7 @@ def imei_type(number):
def is_valid(number):
- """Checks to see if the number provided is a valid IMEI (or IMEISV)
- number."""
+ """Check if the number provided is a valid IMEI (or IMEISV) number."""
try:
return bool(validate(number))
except ValidationError:
@@ -103,7 +101,7 @@ def split(number):
def format(number, separator='-', add_check_digit=False):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
if len(number) == 14 and add_check_digit:
number += luhn.calc_check_digit(number)
diff --git a/stdnum/imo.py b/stdnum/imo.py
index a423bf3..a450bad 100644
--- a/stdnum/imo.py
+++ b/stdnum/imo.py
@@ -59,8 +59,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -72,8 +72,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
try:
return bool(validate(number))
except ValidationError:
@@ -81,5 +81,5 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
return 'IMO ' + compact(number)
diff --git a/stdnum/imsi.py b/stdnum/imsi.py
index c5c3f1e..666f5e4 100644
--- a/stdnum/imsi.py
+++ b/stdnum/imsi.py
@@ -60,7 +60,7 @@ def split(number):
def validate(number):
- """Checks to see if the number provided is a valid IMSI."""
+ """Check if the number provided is a valid IMSI."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -89,7 +89,7 @@ def info(number):
def is_valid(number):
- """Checks to see if the number provided is a valid IMSI."""
+ """Check if the number provided is a valid IMSI."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/is_/kennitala.py b/stdnum/is_/kennitala.py
index 55647eb..7439fad 100644
--- a/stdnum/is_/kennitala.py
+++ b/stdnum/is_/kennitala.py
@@ -72,9 +72,9 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid kennitala. It
- checks the format, whether a valid date is given and whether the
- check digit is correct."""
+ """Check if the number provided is a valid kennitala. It checks the
+ format, whether a valid date is given and whether the check digit is
+ correct."""
number = compact(number)
match = _kennitala_re.search(number)
if not match:
@@ -101,9 +101,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid HETU. It checks the
- format, whether a valid date is given and whether the check digit is
- correct."""
+ """Check if the number provided is a valid HETU. It checks the format,
+ whether a valid date is given and whether the check digit is correct."""
try:
return bool(validate(number))
except ValidationError:
@@ -111,6 +110,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:6] + '-' + number[6:]
diff --git a/stdnum/is_/vsk.py b/stdnum/is_/vsk.py
index 0baf895..e4cc552 100644
--- a/stdnum/is_/vsk.py
+++ b/stdnum/is_/vsk.py
@@ -44,8 +44,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length and formatting."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length and formatting."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -55,8 +55,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length and formatting."""
+ """Check if the number provided is a valid VAT number. This checks the
+ length and formatting."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/isan.py b/stdnum/isan.py
index c0f47bd..4f98218 100644
--- a/stdnum/isan.py
+++ b/stdnum/isan.py
@@ -53,9 +53,9 @@ from stdnum.util import clean
def split(number):
- """Splits the number into a root, an episode or part, a check digit a
- version and another check digit. If any of the parts are missing an
- empty string is returned."""
+ """Split the number into a root, an episode or part, a check digit a
+ version and another check digit. If any of the parts are missing an empty
+ string is returned."""
number = clean(number, ' -').strip().upper()
if len(number) == 17 or len(number) == 26:
return number[0:12], number[12:16], number[16], number[17:25],
number[25:]
@@ -76,9 +76,9 @@ def compact(number, strip_check_digits=True):
def validate(number, strip_check_digits=False, add_check_digits=False):
- """Checks to see if the number provided is a valid ISAN. If check digits
- are present in the number they are validated. If strip_check_digits is
- True any existing check digits will be removed (after checking). If
+ """Check if the number provided is a valid ISAN. If check digits are
+ present in the number they are validated. If strip_check_digits is True
+ any existing check digits will be removed (after checking). If
add_check_digits is True the check digit will be added if they are not
present yet."""
(root, episode, check1, version, check2) = split(number)
@@ -107,8 +107,8 @@ def validate(number, strip_check_digits=False,
add_check_digits=False):
def is_valid(number):
- """Checks to see if the number provided is a valid ISAN. If check digits
- are present in the number they are validated."""
+ """Check if the number provided is a valid ISAN. If check digits are
+ present in the number they are validated."""
try:
return bool(validate(number))
except ValidationError:
@@ -116,7 +116,7 @@ def is_valid(number):
def format(number, separator='-', strip_check_digits=False,
add_check_digits=True):
- """Reformat the passed number to the standard format. If
+ """Reformat the number to the standard presentation format. If
add_check_digits is True the check digit will be added if they are not
present yet. If both strip_check_digits and add_check_digits are True the
check digits will be recalculated."""
@@ -145,12 +145,12 @@ def to_binary(number):
def to_xml(number):
- """Returns the XML form of the ISAN as a string."""
+ """Return the XML form of the ISAN as a string."""
number = format(number, strip_check_digits=True, add_check_digits=False)
return '<ISAN root="%s" episode="%s" version="%s" />' % (
number[0:14], number[15:19], number[20:])
def to_urn(number):
- """Returns the URN representation of the ISAN."""
+ """Return the URN representation of the ISAN."""
return 'URN:ISAN:' + format(number, add_check_digits=True)
diff --git a/stdnum/isbn.py b/stdnum/isbn.py
index e80f58a..d705958 100644
--- a/stdnum/isbn.py
+++ b/stdnum/isbn.py
@@ -88,10 +88,9 @@ def _calc_isbn10_check_digit(number):
def validate(number, convert=False):
- """Checks to see if the number provided is a valid ISBN (either a legacy
- 10-digit one or a 13-digit one). This checks the length and the check
- bit but does not check if the group and publisher are valid (use split()
- for that)."""
+ """Check if the number provided is a valid ISBN (either a legacy 10-digit
+ one or a 13-digit one). This checks the length and the check bit but does
+ not check if the group and publisher are valid (use split() for that)."""
number = compact(number, convert=False)
if not number[:-1].isdigit():
raise InvalidFormat()
@@ -110,7 +109,7 @@ def validate(number, convert=False):
def isbn_type(number):
- """Check the passed number and returns 'ISBN13', 'ISBN10' or None (for
+ """Check the passed number and return 'ISBN13', 'ISBN10' or None (for
invalid) for checking the type of number passed."""
try:
number = validate(number, convert=False)
@@ -123,10 +122,9 @@ def isbn_type(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ISBN (either a legacy
- 10-digit one or a 13-digit one). This checks the length and the check
- bit but does not check if the group and publisher are valid (use split()
- for that)."""
+ """Check if the number provided is a valid ISBN (either a legacy 10-digit
+ one or a 13-digit one). This checks the length and the check bit but does
+ not check if the group and publisher are valid (use split() for that)."""
try:
return bool(validate(number))
except ValidationError:
@@ -198,10 +196,10 @@ def split(number, convert=False):
def format(number, separator='-', convert=False):
- """Reformat the passed number to the standard format with the EAN.UCC
- prefix (if any), the group prefix, the registrant, the item number and
- the check-digit separated (if possible) by the specified separator.
- Passing an empty separator should equal compact() though this is less
- efficient. If the covert parameter is True the number is converted to
- ISBN-13 format first."""
+ """Reformat the number to the standard presentation format with the
+ EAN.UCC prefix (if any), the group prefix, the registrant, the item
+ number and the check-digit separated (if possible) by the specified
+ separator. Passing an empty separator should equal compact() though this
+ is less efficient. If the covert parameter is True the number is
+ converted to ISBN-13 format first."""
return separator.join(x for x in split(number, convert) if x)
diff --git a/stdnum/isil.py b/stdnum/isil.py
index d16cc46..00bd65a 100644
--- a/stdnum/isil.py
+++ b/stdnum/isil.py
@@ -71,7 +71,7 @@ def compact(number):
def _is_known_agency(agency):
- """Checks whether the specified agency is valid."""
+ """Check whether the specified agency is valid."""
# look it up in the db
from stdnum import numdb
results = numdb.get('isil').info(agency.upper() + '$')
@@ -80,7 +80,7 @@ def _is_known_agency(agency):
def validate(number):
- """Checks to see if the number provided is a valid ISIL."""
+ """Check if the number provided is a valid ISIL."""
number = compact(number)
if not all(x in _alphabet for x in number):
raise InvalidFormat()
@@ -92,7 +92,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ISIL."""
+ """Check if the number provided is a valid ISIL."""
try:
return bool(validate(number))
except ValidationError:
@@ -100,7 +100,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
parts = number.split('-')
if len(parts) > 1 and _is_known_agency(parts[0]):
diff --git a/stdnum/isin.py b/stdnum/isin.py
index 47c4560..e82cba6 100644
--- a/stdnum/isin.py
+++ b/stdnum/isin.py
@@ -96,8 +96,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
number = compact(number)
if not all(x in _alphabet for x in number):
raise InvalidFormat()
@@ -111,8 +111,8 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length
- and check digit."""
+ """Check if the number provided is valid. This checks the length and
+ check digit."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ismn.py b/stdnum/ismn.py
index d7337f0..bedc31d 100644
--- a/stdnum/ismn.py
+++ b/stdnum/ismn.py
@@ -54,9 +54,9 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid ISMN (either a legacy
- 10-digit one or a 13-digit one). This checks the length and the check
- bit but does not check if the publisher is known."""
+ """Check if the number provided is a valid ISMN (either a legacy 10-digit
+ one or a 13-digit one). This checks the length and the check bit but does
+ not check if the publisher is known."""
number = compact(number)
if len(number) == 10:
if number[0] != 'M':
@@ -85,9 +85,9 @@ def ismn_type(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ISMN (either a legacy
- 10-digit one or a 13-digit one). This checks the length and the check
- bit but does not check if the publisher is known."""
+ """Check if the number provided is a valid ISMN (either a legacy 10-digit
+ one or a 13-digit one). This checks the length and the check bit but does
+ not check if the publisher is known."""
try:
return bool(validate(number))
except ValidationError:
@@ -129,7 +129,7 @@ def split(number):
def format(number, separator='-'):
- """Reformat the passed number to the standard format with the
+ """Reformat the number to the standard presentation format with the
prefixes, the publisher element, the item element and the check-digit
separated by the specified separator. The number is converted to the
13-digit format silently."""
diff --git a/stdnum/iso6346.py b/stdnum/iso6346.py
index 6a60321..b16fd99 100644
--- a/stdnum/iso6346.py
+++ b/stdnum/iso6346.py
@@ -90,6 +90,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return ' '.join((number[:4], number[4:-1], number[-1:]))
diff --git a/stdnum/iso7064/mod_11_10.py b/stdnum/iso7064/mod_11_10.py
index 690682b..bab172f 100644
--- a/stdnum/iso7064/mod_11_10.py
+++ b/stdnum/iso7064/mod_11_10.py
@@ -47,13 +47,13 @@ def checksum(number):
def calc_check_digit(number):
- """With the provided number, calculate the extra digit that should be
- appended to make it a valid number."""
+ """Calculate the extra digit that should be appended to the number to
+ make it a valid number."""
return str((1 - ((checksum(number) or 10) * 2) % 11) % 10)
def validate(number):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
valid = checksum(number) == 1
except Exception:
@@ -64,7 +64,7 @@ def validate(number):
def is_valid(number):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/iso7064/mod_11_2.py b/stdnum/iso7064/mod_11_2.py
index 9d7c253..daee35d 100644
--- a/stdnum/iso7064/mod_11_2.py
+++ b/stdnum/iso7064/mod_11_2.py
@@ -49,14 +49,14 @@ def checksum(number):
def calc_check_digit(number):
- """With the provided number, calculate the extra digit that should be
- appended to make it a valid number."""
+ """Calculate the extra digit that should be appended to the number to
+ make it a valid number."""
c = (1 - 2 * checksum(number)) % 11
return 'X' if c == 10 else str(c)
def validate(number):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
valid = checksum(number) == 1
except Exception:
@@ -67,7 +67,7 @@ def validate(number):
def is_valid(number):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/iso7064/mod_37_2.py b/stdnum/iso7064/mod_37_2.py
index ece48cb..99a5288 100644
--- a/stdnum/iso7064/mod_37_2.py
+++ b/stdnum/iso7064/mod_37_2.py
@@ -53,14 +53,14 @@ def checksum(number,
alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*'):
def calc_check_digit(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*'):
- """With the provided number, calculate the extra digit that should be
- appended to make it a valid number."""
+ """Calculate the extra digit that should be appended to the number to
+ make it a valid number."""
modulus = len(alphabet)
return alphabet[(1 - 2 * checksum(number, alphabet)) % modulus]
def validate(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*'):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
valid = checksum(number, alphabet) == 1
except Exception:
@@ -71,7 +71,7 @@ def validate(number,
alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*'):
def is_valid(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*'):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
return bool(validate(number, alphabet))
except ValidationError:
diff --git a/stdnum/iso7064/mod_37_36.py b/stdnum/iso7064/mod_37_36.py
index 0787e5a..6b3dea5 100644
--- a/stdnum/iso7064/mod_37_36.py
+++ b/stdnum/iso7064/mod_37_36.py
@@ -51,14 +51,14 @@ def checksum(number,
alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
def calc_check_digit(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
- """With the provided number, calculate the extra digit that should be
- appended to make it a valid number."""
+ """Calculate the extra digit that should be appended to the number to
+ make it a valid number."""
modulus = len(alphabet)
return alphabet[(1 - ((checksum(number, alphabet) or modulus) * 2) %
(modulus + 1)) % modulus]
def validate(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
valid = checksum(number, alphabet) == 1
except Exception:
@@ -69,7 +69,7 @@ def validate(number,
alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
def is_valid(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
return bool(validate(number, alphabet))
except ValidationError:
diff --git a/stdnum/iso7064/mod_97_10.py b/stdnum/iso7064/mod_97_10.py
index 606e4ac..f5cae92 100644
--- a/stdnum/iso7064/mod_97_10.py
+++ b/stdnum/iso7064/mod_97_10.py
@@ -52,13 +52,13 @@ def checksum(number):
def calc_check_digits(number):
- """With the provided number, calculate the extra digits that should be
- appended to make it a valid number."""
+ """Calculate the extra digits that should be appended to the number to
+ make it a valid number."""
return '%02d' % ((98 - 100 * checksum(number)) % 97)
def validate(number):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
valid = checksum(number) == 1
except Exception:
@@ -69,7 +69,7 @@ def validate(number):
def is_valid(number):
- """Checks whether the check digit is valid."""
+ """Check whether the check digit is valid."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/iso9362.py b/stdnum/iso9362.py
index 7844617..80006ad 100644
--- a/stdnum/iso9362.py
+++ b/stdnum/iso9362.py
@@ -59,8 +59,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid routing number. This
- checks the length and characters in each position."""
+ """Check if the number is a valid routing number. This checks the length
+ and characters in each position."""
number = compact(number)
if len(number) not in (8, 11):
raise InvalidLength()
@@ -71,8 +71,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid BIC. This checks the
- length and characters in each position."""
+ """Check if the number provided is a valid BIC."""
try:
return bool(validate(number))
except ValidationError:
@@ -80,5 +79,5 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
return compact(number)
diff --git a/stdnum/issn.py b/stdnum/issn.py
index 4fa113d..07e10e8 100644
--- a/stdnum/issn.py
+++ b/stdnum/issn.py
@@ -69,8 +69,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid ISSN. This checks
- the length and whether the check digit is correct."""
+ """Check if the number is a valid ISSN. This checks the length and
+ whether the check digit is correct."""
number = compact(number)
if not number[:-1].isdigit():
raise InvalidFormat()
@@ -82,8 +82,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ISSN. This checks
- the length and whether the check digit is correct."""
+ """Check if the number provided is a valid ISSN."""
try:
return bool(validate(number))
except ValidationError:
@@ -91,7 +90,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:4] + '-' + number[4:]
diff --git a/stdnum/it/codicefiscale.py b/stdnum/it/codicefiscale.py
index b7f27ea..0d3a4e3 100644
--- a/stdnum/it/codicefiscale.py
+++ b/stdnum/it/codicefiscale.py
@@ -94,8 +94,8 @@ def calc_check_digit(number):
def get_birth_date(number, minyear=1920):
"""Get the birth date from the person's fiscal code.
- Only the last two digits of the year are stured in the number. The
- dates will be returned in the range from minyear to minyear + 100.
+ Only the last two digits of the year are stored in the number. The dates
+ will be returned in the range from minyear to minyear + 100.
>>> get_birth_date('RCCMNL83S18D969H')
datetime.date(1983, 11, 18)
@@ -129,8 +129,8 @@ def get_gender(number):
def validate(number):
- """Checks to see if the given fiscal code is valid. This checks the
- length and whether the check digit is correct."""
+ """Check if the given fiscal code is valid. This checks the length and
+ whether the check digit is correct."""
number = compact(number)
if len(number) != 16:
raise InvalidLength()
@@ -144,8 +144,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the given fiscal code is valid. This checks the
- length and whether the check digit is correct."""
+ """Check if the given fiscal code is valid."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/it/iva.py b/stdnum/it/iva.py
index fdfdfca..a404711 100644
--- a/stdnum/it/iva.py
+++ b/stdnum/it/iva.py
@@ -49,8 +49,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit() or int(number[0:7]) == 0:
raise InvalidFormat()
@@ -65,8 +65,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/lei.py b/stdnum/lei.py
index f87bbee..376fd47 100644
--- a/stdnum/lei.py
+++ b/stdnum/lei.py
@@ -52,16 +52,15 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is valid. This checks the length,
- format and check digits."""
+ """Check if the number is valid. This checks the length, format and check
+ digits."""
number = compact(number)
mod_97_10.validate(number)
return number
def is_valid(number):
- """Checks to see if the number provided is valid. This checks the length,
- format and check digits."""
+ """Check if the number is valid."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/lt/pvm.py b/stdnum/lt/pvm.py
index b5b2016..aadbb4a 100644
--- a/stdnum/lt/pvm.py
+++ b/stdnum/lt/pvm.py
@@ -60,8 +60,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -81,8 +81,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/lu/tva.py b/stdnum/lu/tva.py
index 5fe9896..394f9cb 100644
--- a/stdnum/lu/tva.py
+++ b/stdnum/lu/tva.py
@@ -51,8 +51,8 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -64,8 +64,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/luhn.py b/stdnum/luhn.py
index 5a11a0d..afa4829 100644
--- a/stdnum/luhn.py
+++ b/stdnum/luhn.py
@@ -59,7 +59,7 @@ def checksum(number, alphabet='0123456789'):
def validate(number, alphabet='0123456789'):
- """Checks to see if the number provided passes the Luhn checksum."""
+ """Check if the number provided passes the Luhn checksum."""
if not bool(number):
raise InvalidFormat()
try:
@@ -72,7 +72,7 @@ def validate(number, alphabet='0123456789'):
def is_valid(number, alphabet='0123456789'):
- """Checks to see if the number provided passes the Luhn checksum."""
+ """Check if the number passes the Luhn checksum."""
try:
return bool(validate(number, alphabet))
except ValidationError:
@@ -80,7 +80,7 @@ def is_valid(number, alphabet='0123456789'):
def calc_check_digit(number, alphabet='0123456789'):
- """With the provided number, calculate the extra digit that should be
- appended to make it pass the Luhn checksum."""
+ """Calculate the extra digit that should be appended to the number to
+ make it a valid number."""
ck = checksum(str(number) + alphabet[0], alphabet)
return alphabet[-ck]
diff --git a/stdnum/lv/pvn.py b/stdnum/lv/pvn.py
index e230c2f..5ac0974 100644
--- a/stdnum/lv/pvn.py
+++ b/stdnum/lv/pvn.py
@@ -87,8 +87,8 @@ def get_birth_date(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -108,8 +108,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/mc/tva.py b/stdnum/mc/tva.py
index 9acb222..0fe3bf5 100644
--- a/stdnum/mc/tva.py
+++ b/stdnum/mc/tva.py
@@ -45,8 +45,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = tva.validate(number)
if number[2:5] != '000':
raise InvalidComponent()
@@ -54,8 +54,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/meid.py b/stdnum/meid.py
index db43866..c5a349a 100644
--- a/stdnum/meid.py
+++ b/stdnum/meid.py
@@ -106,7 +106,7 @@ def compact(number, strip_check_digit=True):
def _bit_length(n):
- """Number of bits necessary to represent the number in binary."""
+ """Return the number of bits necessary to store the number in binary."""
try:
return n.bit_length()
except AttributeError: # pragma: no cover (Python 2.6 only)
@@ -115,9 +115,9 @@ def _bit_length(n):
def validate(number, strip_check_digit=True):
- """Checks to see if the number provided is a valid MEID number. This
- converts the representation format of the number (if it is
- decimal it is not converted to hexadecimal)."""
+ """Check if the number is a valid MEID number. This converts the
+ representation format of the number (if it is decimal it is not converted
+ to hexadecimal)."""
from stdnum import luhn
# first parse the number
number, cd = _parse(number)
@@ -146,7 +146,7 @@ def validate(number, strip_check_digit=True):
def is_valid(number):
- """Checks to see if the number provided is a valid MEID number."""
+ """Check if the number is a valid MEID number."""
try:
return bool(validate(number))
except ValidationError:
@@ -154,11 +154,11 @@ def is_valid(number):
def format(number, separator=' ', format=None, add_check_digit=False):
- """Reformat the passed number to the standard format. The separator
- used can be provided. If the format is specified (either 'hex' or
- 'dec') the number is reformatted in that format, otherwise the current
- representation is kept. If add_check_digit is True a check digit will
- be added if it is not present yet."""
+ """Reformat the number to the standard presentation format. The separator
+ used can be provided. If the format is specified (either 'hex' or 'dec')
+ the number is reformatted in that format, otherwise the current
+ representation is kept. If add_check_digit is True a check digit will be
+ added if it is not present yet."""
# first parse the number
number, cd = _parse(number)
# format conversions if needed
diff --git a/stdnum/mt/vat.py b/stdnum/mt/vat.py
index 357c8f2..61d2f83 100644
--- a/stdnum/mt/vat.py
+++ b/stdnum/mt/vat.py
@@ -50,8 +50,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit() or number[0] == '0':
raise InvalidFormat()
@@ -63,8 +63,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/mx/rfc.py b/stdnum/mx/rfc.py
index 10da251..87acbe8 100644
--- a/stdnum/mx/rfc.py
+++ b/stdnum/mx/rfc.py
@@ -116,7 +116,7 @@ def calc_check_digit(number):
def validate(number, validate_check_digits=False):
- """Checks to see if the number provided is a valid number."""
+ """Check if the number is a valid RFC."""
number = compact(number)
if not _rfc_re.match(number):
raise InvalidFormat()
@@ -139,7 +139,7 @@ def validate(number, validate_check_digits=False):
def is_valid(number, validate_check_digits=False):
- """Checks to see if the number provided is a valid number."""
+ """Check if the number provided is a valid RFC."""
try:
return bool(validate(number, validate_check_digits))
except ValidationError:
@@ -147,7 +147,7 @@ def is_valid(number, validate_check_digits=False):
def format(number, separator=' '):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
if len(number) == 12:
return separator.join((
diff --git a/stdnum/my/nric.py b/stdnum/my/nric.py
index 0eb8844..7817228 100644
--- a/stdnum/my/nric.py
+++ b/stdnum/my/nric.py
@@ -85,8 +85,8 @@ def get_birth_place(number):
def validate(number):
- """Checks to see if the number provided is a valid NRIC numbers. This
- checks the length, formatting and birth date and place."""
+ """Check if the number is a valid NRIC number. This checks the length,
+ formatting and birth date and place."""
number = compact(number)
if len(number) != 12:
raise InvalidLength()
@@ -98,8 +98,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid NRIC numbers. This
- checks the length, formatting and birth date and place."""
+ """Check if the number is a valid NRIC number."""
try:
return bool(validate(number))
except ValidationError:
@@ -107,6 +106,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:6] + '-' + number[6:8] + '-' + number[8:]
diff --git a/stdnum/nl/brin.py b/stdnum/nl/brin.py
index bf9db25..af17ed8 100644
--- a/stdnum/nl/brin.py
+++ b/stdnum/nl/brin.py
@@ -60,9 +60,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is in the correct format.
- This currently does not check whether the number points to a
- registered school."""
+ """Check if the number is a valid Brun number. This currently does not
+ check whether the number points to a registered school."""
number = compact(number)
if len(number) not in (4, 6):
raise InvalidLength()
@@ -73,7 +72,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid Brin number."""
+ """Check if the number is a valid Brun number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/nl/bsn.py b/stdnum/nl/bsn.py
index c9e6f57..f493ed5 100644
--- a/stdnum/nl/bsn.py
+++ b/stdnum/nl/bsn.py
@@ -63,8 +63,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid BSN. This checks
- the length and whether the check digit is correct."""
+ """Check if the number is a valid BSN. This checks the length and whether
+ the check digit is correct."""
number = compact(number)
if not number.isdigit() or int(number) <= 0:
raise InvalidFormat()
@@ -76,8 +76,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid BSN. This checks
- the length and whether the check digit is correct."""
+ """Check if the number is a valid BSN."""
try:
return bool(validate(number))
except ValidationError:
@@ -85,6 +84,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the passed number to the standard presentation format."""
number = compact(number)
return number[:4] + '.' + number[4:6] + '.' + number[6:]
diff --git a/stdnum/nl/btw.py b/stdnum/nl/btw.py
index 77a7981..6702d9f 100644
--- a/stdnum/nl/btw.py
+++ b/stdnum/nl/btw.py
@@ -48,8 +48,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid BTW number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid BTW number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number[10:].isdigit() or int(number[10:]) <= 0:
raise InvalidFormat()
@@ -62,8 +62,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid BTW number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid BTW number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/nl/onderwijsnummer.py b/stdnum/nl/onderwijsnummer.py
index b8d32c4..0997ada 100644
--- a/stdnum/nl/onderwijsnummer.py
+++ b/stdnum/nl/onderwijsnummer.py
@@ -51,9 +51,9 @@ __all__ = ['compact', 'validate', 'is_valid']
def validate(number):
- """Checks to see if the number provided is a valid onderwijsnummer.
- This checks the length and whether the check digit is correct and
- whether it starts with the right sequence."""
+ """Check if the number is a valid onderwijsnummer. This checks the length
+ and whether the check digit is correct and whether it starts with the
+ right sequence."""
number = compact(number)
if not number.isdigit() or int(number) <= 0:
raise InvalidFormat()
@@ -67,9 +67,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid onderwijsnummer.
- This checks the length and whether the check digit is correct and
- whether it starts with the right sequence."""
+ """Check if the number is a valid onderwijsnummer."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/nl/postcode.py b/stdnum/nl/postcode.py
index 90674d7..91fe543 100644
--- a/stdnum/nl/postcode.py
+++ b/stdnum/nl/postcode.py
@@ -57,9 +57,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is in the correct format.
- This currently does not check whether the code corresponds to a real
- address."""
+ """Check if the number is in the correct format. This currently does not
+ check whether the code corresponds to a real address."""
number = compact(number)
match = _postcode_re.search(number)
if not match:
@@ -70,7 +69,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid postal code."""
+ """Check if the number is a valid postal code."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/no/mva.py b/stdnum/no/mva.py
index f3be4e7..60a1421 100644
--- a/stdnum/no/mva.py
+++ b/stdnum/no/mva.py
@@ -49,8 +49,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid MVA number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid MVA number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.endswith('MVA'):
raise InvalidFormat()
@@ -59,8 +59,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid MVA number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid MVA number."""
try:
return bool(validate(number))
except ValidationError:
@@ -68,6 +67,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return 'NO ' + orgnr.format(number[:9]) + ' ' + number[9:]
diff --git a/stdnum/no/orgnr.py b/stdnum/no/orgnr.py
index 993d9da..ebceac8 100644
--- a/stdnum/no/orgnr.py
+++ b/stdnum/no/orgnr.py
@@ -52,8 +52,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid organisation number.
- This checks the length, formatting and check digit."""
+ """Check if the number is a valid organisation number. This checks the
+ length, formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -65,8 +65,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid organisation number.
- This checks the length, formatting and check digit."""
+ """Check if the number is a valid organisation number."""
try:
return bool(validate(number))
except ValidationError:
@@ -74,6 +73,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:3] + ' ' + number[3:6] + ' ' + number[6:]
diff --git a/stdnum/numdb.py b/stdnum/numdb.py
index e3e48e2..e04faa6 100644
--- a/stdnum/numdb.py
+++ b/stdnum/numdb.py
@@ -106,8 +106,10 @@ _open_databases = {}
class NumDB(object):
+ """Number database."""
def __init__(self):
+ """Construct an empty database."""
self.prefixes = []
@staticmethod
@@ -195,7 +197,7 @@ def read(fp):
def get(name):
- """Opens a database with the specified name to perform queries on."""
+ """Open a database with the specified name to perform queries on."""
if name not in _open_databases:
import codecs
reader = codecs.getreader('utf-8')
diff --git a/stdnum/pl/nip.py b/stdnum/pl/nip.py
index 8f8bd0f..950b031 100644
--- a/stdnum/pl/nip.py
+++ b/stdnum/pl/nip.py
@@ -52,8 +52,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -65,8 +65,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
@@ -74,6 +73,6 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return '-'.join((number[0:3], number[3:6], number[6:8], number[8:]))
diff --git a/stdnum/pl/pesel.py b/stdnum/pl/pesel.py
index 0f5901d..223b9cb 100644
--- a/stdnum/pl/pesel.py
+++ b/stdnum/pl/pesel.py
@@ -97,9 +97,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid
- national identification number. This checks the length,
- formatting and check digit."""
+ """Check if the number is a valid national identification number. This
+ checks the length, formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -112,9 +111,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid
- national identification number. This checks the length,
- formatting and check digit."""
+ """Check if the number is a valid national identification number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/pl/regon.py b/stdnum/pl/regon.py
index 82af03a..cf3697e 100644
--- a/stdnum/pl/regon.py
+++ b/stdnum/pl/regon.py
@@ -73,8 +73,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid REGON number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid REGON number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -88,8 +88,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid REGON number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid REGON number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/pt/nif.py b/stdnum/pt/nif.py
index 60c2a9f..20c8f77 100644
--- a/stdnum/pt/nif.py
+++ b/stdnum/pt/nif.py
@@ -53,8 +53,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit() or number[0] == '0':
raise InvalidFormat()
@@ -66,8 +66,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ro/cf.py b/stdnum/ro/cf.py
index c953c25..7b07fb9 100644
--- a/stdnum/ro/cf.py
+++ b/stdnum/ro/cf.py
@@ -56,8 +56,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit() or number[0] == '0':
raise InvalidFormat()
@@ -73,8 +73,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ro/cnp.py b/stdnum/ro/cnp.py
index ad27149..6aab9ef 100644
--- a/stdnum/ro/cnp.py
+++ b/stdnum/ro/cnp.py
@@ -75,8 +75,8 @@ def get_birth_date(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
# first digit should be a known one (9=foreigner)
if not number.isdigit() or number[0] not in '1234569':
@@ -93,8 +93,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/rs/pib.py b/stdnum/rs/pib.py
index cf530c5..73b46fe 100644
--- a/stdnum/rs/pib.py
+++ b/stdnum/rs/pib.py
@@ -43,8 +43,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -55,8 +55,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/ru/inn.py b/stdnum/ru/inn.py
index 1f27bb0..30f16d5 100644
--- a/stdnum/ru/inn.py
+++ b/stdnum/ru/inn.py
@@ -67,8 +67,8 @@ def calc_personal_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid ИНН. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid ИНН. This checks the length, formatting
+ and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -85,8 +85,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ИНН. This checks the
- length, formatting and check digit."""
+ """Check if the number is a valid ИНН."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/se/orgnr.py b/stdnum/se/orgnr.py
index 339f624..65f300c 100644
--- a/stdnum/se/orgnr.py
+++ b/stdnum/se/orgnr.py
@@ -48,7 +48,7 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This checks
+ """Check if the number is a valid organisation number. This checks
the length, formatting and check digit."""
number = compact(number)
if not number.isdigit():
@@ -59,8 +59,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This checks
- the length, formatting and check digit."""
+ """Check if the number is a valid organisation number"""
try:
return bool(validate(number))
except ValidationError:
@@ -68,6 +67,6 @@ def is_valid(number):
def format(number):
- """Reformat the number to the standard format."""
+ """Reformat the number to the standard presentation format."""
number = compact(number)
return number[:6] + '-' + number[6:]
diff --git a/stdnum/se/vat.py b/stdnum/se/vat.py
index 3868828..efaabc4 100644
--- a/stdnum/se/vat.py
+++ b/stdnum/se/vat.py
@@ -47,8 +47,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit() or number[-2:] != '01':
raise InvalidFormat()
@@ -57,8 +57,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/si/ddv.py b/stdnum/si/ddv.py
index 59a156b..5b16dbc 100644
--- a/stdnum/si/ddv.py
+++ b/stdnum/si/ddv.py
@@ -54,8 +54,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit() or number.startswith('0'):
raise InvalidFormat()
@@ -67,8 +67,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/sk/dph.py b/stdnum/sk/dph.py
index 3654316..97e08f2 100644
--- a/stdnum/sk/dph.py
+++ b/stdnum/sk/dph.py
@@ -51,8 +51,8 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number. This checks the length,
+ formatting and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -69,8 +69,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid VAT number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid VAT number."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/sm/coe.py b/stdnum/sm/coe.py
index cb3e487..f40ffaa 100644
--- a/stdnum/sm/coe.py
+++ b/stdnum/sm/coe.py
@@ -58,8 +58,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid number. This checks
- the length and formatting."""
+ """Check if the number is a valid COE. This checks the length and
+ formatting."""
number = compact(number)
if len(number) > 5 or len(number) == 0:
raise InvalidLength()
@@ -71,8 +71,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid number. This
- checks the length, formatting and check digit."""
+ """Check if the number is a valid COE."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/tr/__init__.py b/stdnum/tr/__init__.py
index e69de29..c5fa2f8 100644
--- a/stdnum/tr/__init__.py
+++ b/stdnum/tr/__init__.py
@@ -0,0 +1,21 @@
+# __init__.py - collection of Turkish numbers
+# coding: utf-8
+#
+# Copyright (C) 2016 Arthur de Jong
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+"""Collection of Turkish numbers."""
diff --git a/stdnum/tr/tckimlik.py b/stdnum/tr/tckimlik.py
index 03ff92c..26eebf3 100644
--- a/stdnum/tr/tckimlik.py
+++ b/stdnum/tr/tckimlik.py
@@ -73,8 +73,8 @@ def calc_check_digits(number):
def validate(number):
- """Checks to see if the number provided is a valid .C. Kimlik No..
- This checks the length and check digits"""
+ """Check if the number is a valid .C. Kimlik number. This checks the
+ length and check digits."""
number = compact(number)
if not number.isdigit() or number[0] == '0':
raise InvalidFormat()
@@ -86,8 +86,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid .C. Kimlik No..
- This checks the length and check digits"""
+ """Check if the number is a valid .C. Kimlik number."""
try:
return bool(validate(number))
except ValidationError:
@@ -105,9 +104,9 @@ def _get_client(): # pragma: no cover (no tests for this
function)
def check_kps(number, name, surname, birth_year): # pragma: no cover
- """Queries the online T.C. Kimlik validation service run by the
- Directorate of Population and Citizenship Affairs. This returns a boolean
- but may raise a SOAP exception for missing or invalid values."""
+ """Query the online T.C. Kimlik validation service run by the Directorate
+ of Population and Citizenship Affairs. This returns a boolean but may
+ raise a SOAP exception for missing or invalid values."""
# this function isn't automatically tested because it would require
# network access for the tests and unnecessarily load the online service
number = compact(number)
diff --git a/stdnum/us/atin.py b/stdnum/us/atin.py
index 1a93a75..4ff5953 100644
--- a/stdnum/us/atin.py
+++ b/stdnum/us/atin.py
@@ -52,8 +52,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid ATIN. This checks
- the length and formatting if it is present."""
+ """Check if the number is a valid ATIN. This checks the length and
+ formatting if it is present."""
match = _atin_re.search(clean(number, '').strip())
if not match:
raise InvalidFormat()
@@ -62,8 +62,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ATIN. This checks
- the length and formatting if it is present."""
+ """Check if the number is a valid ATIN."""
try:
return bool(validate(number))
except ValidationError:
@@ -71,7 +70,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
if len(number) == 9:
number = number[:3] + '-' + number[3:5] + '-' + number[5:]
return number
diff --git a/stdnum/us/ein.py b/stdnum/us/ein.py
index 3a50022..75d178c 100644
--- a/stdnum/us/ein.py
+++ b/stdnum/us/ein.py
@@ -69,8 +69,8 @@ def get_campus(number):
def validate(number):
- """Checks to see if the number provided is a valid EIN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid EIN. This checks the length, groups and
+ formatting if it is present."""
match = _ein_re.search(clean(number, '').strip())
if not match:
raise InvalidFormat()
@@ -79,8 +79,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid EIN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid EIN."""
try:
return bool(validate(number))
except ValidationError:
@@ -88,7 +87,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
if len(number) == 9:
number = number[:2] + '-' + number[2:]
return number
diff --git a/stdnum/us/itin.py b/stdnum/us/itin.py
index f8dc544..0d1aa41 100644
--- a/stdnum/us/itin.py
+++ b/stdnum/us/itin.py
@@ -70,8 +70,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid ITIN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid ITIN. This checks the length, groups
+ and formatting if it is present."""
match = _itin_re.search(clean(number, '').strip())
if not match:
raise InvalidFormat()
@@ -83,8 +83,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ITIN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid ITIN."""
try:
return bool(validate(number))
except ValidationError:
@@ -92,7 +91,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
if len(number) == 9:
number = number[:3] + '-' + number[3:5] + '-' + number[5:]
return number
diff --git a/stdnum/us/ptin.py b/stdnum/us/ptin.py
index c4a87fc..7d60f6a 100644
--- a/stdnum/us/ptin.py
+++ b/stdnum/us/ptin.py
@@ -50,8 +50,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid PTIN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid PTIN. This checks the length, groups
+ and formatting if it is present."""
number = compact(number).upper()
if not _ptin_re.search(number):
raise InvalidFormat()
@@ -60,8 +60,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid ATIN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid ATIN."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/us/rtn.py b/stdnum/us/rtn.py
index 17ba1a8..1e544fc 100644
--- a/stdnum/us/rtn.py
+++ b/stdnum/us/rtn.py
@@ -66,8 +66,8 @@ def calc_check_digit(number):
def validate(number):
- """Checks to see if the number provided is a valid routing number. This
- checks the length and check digit."""
+ """Check if the number is a valid routing number. This checks the length
+ and check digit."""
number = compact(number)
if not number.isdigit():
raise InvalidFormat()
@@ -79,8 +79,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid RTN. This checks the
- length and check digit."""
+ """Check if the number is a valid RTN."""
try:
return bool(validate(number))
except ValidationError:
diff --git a/stdnum/us/ssn.py b/stdnum/us/ssn.py
index d08bd9a..78d538e 100644
--- a/stdnum/us/ssn.py
+++ b/stdnum/us/ssn.py
@@ -81,8 +81,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid SSN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid SSN. This checks the length, groups and
+ formatting if it is present."""
match = _ssn_re.search(clean(number, '').strip())
if not match:
raise InvalidFormat()
@@ -101,8 +101,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid SSN. This checks
- the length, groups and formatting if it is present."""
+ """Check if the number is a valid SSN."""
try:
return bool(validate(number))
except ValidationError:
@@ -110,7 +109,7 @@ def is_valid(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
if len(number) == 9:
number = number[:3] + '-' + number[3:5] + '-' + number[5:]
return number
diff --git a/stdnum/us/tin.py b/stdnum/us/tin.py
index b2696b1..edcc7f8 100644
--- a/stdnum/us/tin.py
+++ b/stdnum/us/tin.py
@@ -62,8 +62,8 @@ def compact(number):
def validate(number):
- """Checks to see if the number provided is a valid TIN. This searches
- for the proper sub-type and validates using that."""
+ """Check if the number is a valid TIN. This searches for the proper
+ sub-type and validates using that."""
for mod in _tin_modules:
try:
return mod.validate(number)
@@ -74,8 +74,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided is a valid TIN. This searches
- for the proper sub-type and validates using that."""
+ """Check if the number is a valid TIN."""
try:
return bool(validate(number))
except ValidationError:
@@ -91,7 +90,7 @@ def guess_type(number):
def format(number):
- """Reformat the passed number to the standard format."""
+ """Reformat the number to the standard presentation format."""
for mod in _tin_modules:
if mod.is_valid(number) and hasattr(mod, 'format'):
return mod.format(number)
diff --git a/stdnum/verhoeff.py b/stdnum/verhoeff.py
index 02559d3..e6af854 100644
--- a/stdnum/verhoeff.py
+++ b/stdnum/verhoeff.py
@@ -87,7 +87,7 @@ def checksum(number):
def validate(number):
- """Checks to see if the number provided passes the Verhoeff checksum."""
+ """Check if the number provided passes the Verhoeff checksum."""
if not bool(number):
raise InvalidFormat()
try:
@@ -100,7 +100,7 @@ def validate(number):
def is_valid(number):
- """Checks to see if the number provided passes the Verhoeff checksum."""
+ """Check if the number provided passes the Verhoeff checksum."""
try:
return bool(validate(number))
except ValidationError:
@@ -108,6 +108,6 @@ def is_valid(number):
def calc_check_digit(number):
- """With the provided number, calculate the extra digit that should be
- appended to make it pass the Verhoeff checksum."""
+ """Calculate the extra digit that should be appended to the number to
+ make it a valid number."""
return str(_multiplication_table[checksum(str(number) + '0')].index(0))
-----------------------------------------------------------------------
Summary of changes:
setup.cfg | 5 +++++
stdnum/al/nipt.py | 7 +++----
stdnum/ar/cbu.py | 6 +++---
stdnum/ar/cuit.py | 4 ++--
stdnum/at/businessid.py | 7 +++----
stdnum/at/uid.py | 7 +++----
stdnum/au/abn.py | 9 ++++-----
stdnum/au/acn.py | 9 ++++-----
stdnum/au/tfn.py | 9 ++++-----
stdnum/be/vat.py | 7 +++----
stdnum/bg/egn.py | 11 ++++-------
stdnum/bg/pnf.py | 9 +++------
stdnum/bg/vat.py | 7 +++----
stdnum/br/cnpj.py | 8 ++++----
stdnum/br/cpf.py | 9 ++++-----
stdnum/ca/bn.py | 7 +++----
stdnum/ca/sin.py | 9 ++++-----
stdnum/ch/ssn.py | 8 +++-----
stdnum/ch/uid.py | 9 ++++-----
stdnum/ch/vat.py | 11 +++++------
stdnum/cl/rut.py | 9 ++++-----
stdnum/cn/ric.py | 15 +++++++--------
stdnum/co/nit.py | 9 ++++-----
stdnum/cusip.py | 8 ++++----
stdnum/cy/vat.py | 7 +++----
stdnum/cz/dic.py | 9 ++++-----
stdnum/cz/rc.py | 9 ++++-----
stdnum/damm.py | 8 ++++----
stdnum/de/idnr.py | 10 +++++-----
stdnum/de/vat.py | 8 ++++----
stdnum/de/wkn.py | 8 ++++----
stdnum/dk/cpr.py | 12 ++++++------
stdnum/dk/cvr.py | 8 ++++----
stdnum/do/cedula.py | 8 ++++----
stdnum/do/rnc.py | 6 +++---
stdnum/ean.py | 12 ++++++------
stdnum/ec/ci.py | 8 ++++----
stdnum/ec/ruc.py | 8 ++++----
stdnum/ee/ik.py | 6 +++---
stdnum/ee/kmkr.py | 8 ++++----
stdnum/ee/registrikood.py | 12 +++++-------
stdnum/es/ccc.py | 6 +++---
stdnum/es/cif.py | 8 ++++----
stdnum/es/cups.py | 10 +++++-----
stdnum/es/dni.py | 8 ++++----
stdnum/es/iban.py | 4 ++--
stdnum/es/nie.py | 8 ++++----
stdnum/es/nif.py | 10 +++++-----
stdnum/es/referenciacatastral.py | 11 +++++------
stdnum/eu/at_02.py | 6 +++---
stdnum/eu/eic.py | 8 ++++----
stdnum/eu/nace.py | 12 ++++++------
stdnum/eu/vat.py | 26 +++++++++++++-------------
stdnum/fi/__init__.py | 2 +-
stdnum/fi/alv.py | 7 +++----
stdnum/fi/associationid.py | 13 ++++---------
stdnum/fi/hetu.py | 11 ++++-------
stdnum/fi/veronumero.py | 7 +++----
stdnum/fi/ytunnus.py | 9 ++++-----
stdnum/fr/nif.py | 6 +++---
stdnum/fr/nir.py | 26 +++++++++++++++++---------
stdnum/fr/siren.py | 10 ++++------
stdnum/fr/siret.py | 13 ++++++-------
stdnum/fr/tva.py | 7 +++----
stdnum/gb/nhs.py | 11 +++++------
stdnum/gb/sedol.py | 7 +++----
stdnum/gb/upn.py | 9 ++++-----
stdnum/gb/vat.py | 11 +++++------
stdnum/gr/vat.py | 7 +++----
stdnum/grid.py | 6 +++---
stdnum/hr/oib.py | 7 +++----
stdnum/hu/anum.py | 7 +++----
stdnum/iban.py | 8 ++++----
stdnum/ie/pps.py | 8 ++++----
stdnum/ie/vat.py | 8 ++++----
stdnum/imei.py | 10 ++++------
stdnum/imo.py | 10 +++++-----
stdnum/imsi.py | 4 ++--
stdnum/is_/kennitala.py | 15 +++++++--------
stdnum/is_/vsk.py | 8 ++++----
stdnum/isan.py | 22 +++++++++++-----------
stdnum/isbn.py | 28 +++++++++++++---------------
stdnum/isil.py | 8 ++++----
stdnum/isin.py | 8 ++++----
stdnum/ismn.py | 14 +++++++-------
stdnum/iso6346.py | 2 +-
stdnum/iso7064/mod_11_10.py | 8 ++++----
stdnum/iso7064/mod_11_2.py | 8 ++++----
stdnum/iso7064/mod_37_2.py | 8 ++++----
stdnum/iso7064/mod_37_36.py | 8 ++++----
stdnum/iso7064/mod_97_10.py | 8 ++++----
stdnum/iso9362.py | 9 ++++-----
stdnum/issn.py | 9 ++++-----
stdnum/it/codicefiscale.py | 15 +++++++--------
stdnum/it/iva.py | 7 +++----
stdnum/lei.py | 7 +++----
stdnum/lt/pvm.py | 7 +++----
stdnum/lu/tva.py | 7 +++----
stdnum/luhn.py | 8 ++++----
stdnum/lv/pvn.py | 9 ++++-----
stdnum/mc/tva.py | 7 +++----
stdnum/meid.py | 20 ++++++++++----------
stdnum/mt/vat.py | 7 +++----
stdnum/mx/rfc.py | 6 +++---
stdnum/my/nric.py | 9 ++++-----
stdnum/nl/brin.py | 7 +++----
stdnum/nl/bsn.py | 9 ++++-----
stdnum/nl/btw.py | 7 +++----
stdnum/nl/onderwijsnummer.py | 12 +++++-------
stdnum/nl/postcode.py | 7 +++----
stdnum/no/mva.py | 9 ++++-----
stdnum/no/orgnr.py | 9 ++++-----
stdnum/numdb.py | 7 +++++--
stdnum/pl/nip.py | 9 ++++-----
stdnum/pl/pesel.py | 9 +++------
stdnum/pl/regon.py | 7 +++----
stdnum/pt/nif.py | 7 +++----
stdnum/ro/cf.py | 7 +++----
stdnum/ro/cnp.py | 9 ++++-----
stdnum/rs/pib.py | 9 ++++-----
stdnum/ru/inn.py | 7 +++----
stdnum/se/orgnr.py | 7 +++----
stdnum/se/vat.py | 7 +++----
stdnum/si/ddv.py | 7 +++----
stdnum/sk/dph.py | 7 +++----
stdnum/sk/rc.py | 2 +-
stdnum/sm/coe.py | 7 +++----
stdnum/tr/__init__.py | 21 +++++++++++++++++++++
stdnum/tr/tckimlik.py | 13 ++++++-------
stdnum/us/atin.py | 9 ++++-----
stdnum/us/ein.py | 9 ++++-----
stdnum/us/itin.py | 9 ++++-----
stdnum/us/ptin.py | 7 +++----
stdnum/us/rtn.py | 7 +++----
stdnum/us/ssn.py | 9 ++++-----
stdnum/us/tin.py | 11 +++++------
stdnum/util.py | 2 +-
stdnum/verhoeff.py | 8 ++++----
tox.ini | 22 +++++++++++++++++++++-
139 files changed, 606 insertions(+), 648 deletions(-)
hooks/post-receive
--
python-stdnum
--
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-stdnum-commits/
- python-stdnum branch master updated. 1.6-22-gedaad05,
Commits of the python-stdnum project