update path, add python unrar
This commit is contained in:
parent
642ba49f68
commit
00165d302e
862 changed files with 804 additions and 6 deletions
24
Shared/lib/python3.7/site-packages/stdnum/pl/__init__.py
Normal file
24
Shared/lib/python3.7/site-packages/stdnum/pl/__init__.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# __init__.py - collection of Polish numbers
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright (C) 2012 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 Polish numbers."""
|
||||
|
||||
# provide vat as an alias
|
||||
from stdnum.pl import nip as vat
|
||||
79
Shared/lib/python3.7/site-packages/stdnum/pl/nip.py
Normal file
79
Shared/lib/python3.7/site-packages/stdnum/pl/nip.py
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# nip.py - functions for handling Polish VAT numbers
|
||||
#
|
||||
# Copyright (C) 2012-2015 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
|
||||
|
||||
"""NIP (Numer Identyfikacji Podatkowej, Polish VAT number).
|
||||
|
||||
The NIP (Numer Identyfikacji Podatkowej) number consists of 10 digit with
|
||||
a straightforward weighted checksum.
|
||||
|
||||
>>> validate('PL 8567346215')
|
||||
'8567346215'
|
||||
>>> validate('PL 8567346216') # invalid check digits
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
InvalidChecksum: ...
|
||||
>>> format('PL 8567346215')
|
||||
'856-734-62-15'
|
||||
"""
|
||||
|
||||
from stdnum.exceptions import *
|
||||
from stdnum.util import clean
|
||||
|
||||
|
||||
def compact(number):
|
||||
"""Convert the number to the minimal representation. This strips the
|
||||
number of any valid separators and removes surrounding whitespace."""
|
||||
number = clean(number, ' -').upper().strip()
|
||||
if number.startswith('PL'):
|
||||
number = number[2:]
|
||||
return number
|
||||
|
||||
|
||||
def checksum(number):
|
||||
"""Calculate the checksum."""
|
||||
weights = (6, 5, 7, 2, 3, 4, 5, 6, 7, -1)
|
||||
return sum(w * int(n) for w, n in zip(weights, number)) % 11
|
||||
|
||||
|
||||
def validate(number):
|
||||
"""Checks to see 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()
|
||||
if len(number) != 10:
|
||||
raise InvalidLength()
|
||||
if checksum(number) != 0:
|
||||
raise InvalidChecksum()
|
||||
return 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."""
|
||||
try:
|
||||
return bool(validate(number))
|
||||
except ValidationError:
|
||||
return False
|
||||
|
||||
|
||||
def format(number):
|
||||
"""Reformat the passed number to the standard format."""
|
||||
number = compact(number)
|
||||
return '-'.join((number[0:3], number[3:6], number[6:8], number[8:]))
|
||||
121
Shared/lib/python3.7/site-packages/stdnum/pl/pesel.py
Normal file
121
Shared/lib/python3.7/site-packages/stdnum/pl/pesel.py
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
# pesel.py - functions for handling Polish national identification numbers
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright (C) 2015 Dariusz Choruzy
|
||||
# Copyright (C) 2015 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
|
||||
|
||||
"""PESEL (Polish national identification number).
|
||||
|
||||
The Powszechny Elektroniczny System Ewidencji Ludności (PESEL, Universal
|
||||
Electronic System for Registration of the Population) is a 11-digit Polish
|
||||
national identification number. The number consists of the date of birth,
|
||||
a serial number, the person's gender and a check digit.
|
||||
|
||||
|
||||
>>> validate('44051401359')
|
||||
'44051401359'
|
||||
>>> validate('44051401358') # incorrect check digit
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
InvalidChecksum: ...
|
||||
>>> validate('02381307589') # invalid birth date
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
InvalidComponent: ...
|
||||
>>> get_birth_date('02122401358')
|
||||
datetime.date(1902, 12, 24)
|
||||
>>> get_gender('02122401358')
|
||||
'M'
|
||||
>>> get_birth_date('02211307589')
|
||||
datetime.date(2002, 1, 13)
|
||||
>>> get_gender('02211307589')
|
||||
'F'
|
||||
"""
|
||||
|
||||
import datetime
|
||||
|
||||
from stdnum.exceptions import *
|
||||
from stdnum.util import clean
|
||||
|
||||
|
||||
def compact(number):
|
||||
"""Convert the number to the minimal representation. This strips the
|
||||
number of any valid separators and removes surrounding whitespace."""
|
||||
return clean(number, ' -').upper().strip()
|
||||
|
||||
|
||||
def get_birth_date(number):
|
||||
"""Split the date parts from the number and return the birth date."""
|
||||
number = compact(number)
|
||||
year = int(number[0:2])
|
||||
month = int(number[2:4])
|
||||
day = int(number[4:6])
|
||||
year += {
|
||||
0: 1900,
|
||||
1: 2000,
|
||||
2: 2100,
|
||||
3: 2200,
|
||||
4: 1800,
|
||||
}[month // 20]
|
||||
month = month % 20
|
||||
try:
|
||||
return datetime.date(year, month, day)
|
||||
except ValueError:
|
||||
raise InvalidComponent()
|
||||
|
||||
|
||||
def get_gender(number):
|
||||
"""Get the person's birth gender ('M' or 'F')."""
|
||||
number = compact(number)
|
||||
if number[9] in '02468': # even
|
||||
return 'F'
|
||||
else: # odd: 13579
|
||||
return 'M'
|
||||
|
||||
|
||||
def calc_check_digit(number):
|
||||
"""Calculate the check digit for organisations. The number passed
|
||||
should not have the check digit included."""
|
||||
weights = (1, 3, 7, 9, 1, 3, 7, 9, 1, 3)
|
||||
check = sum(w * int(n) for w, n in zip(weights, number))
|
||||
return str((10 - check) % 10)
|
||||
|
||||
|
||||
def validate(number):
|
||||
"""Checks to see if the number provided is a valid
|
||||
national identification number. This checks the length,
|
||||
formatting and check digit."""
|
||||
number = compact(number)
|
||||
if not number.isdigit():
|
||||
raise InvalidFormat()
|
||||
if len(number) != 11:
|
||||
raise InvalidLength()
|
||||
if number[-1] != calc_check_digit(number[:-1]):
|
||||
raise InvalidChecksum()
|
||||
get_birth_date(number)
|
||||
return 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."""
|
||||
try:
|
||||
return bool(validate(number))
|
||||
except ValidationError:
|
||||
return False
|
||||
95
Shared/lib/python3.7/site-packages/stdnum/pl/regon.py
Normal file
95
Shared/lib/python3.7/site-packages/stdnum/pl/regon.py
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# pesel.py - functions for handling REGON numbers
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright (C) 2015 Dariusz Choruzy
|
||||
# Copyright (C) 2015 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
|
||||
|
||||
"""REGON (Rejestr Gospodarki Narodowej, Polish register of economic units).
|
||||
|
||||
The REGON (Rejestr Gospodarki Narodowej) is a statistical identification
|
||||
number for businesses. National entities are assigned a 9-digit number, while
|
||||
local units append 5 digits to form a 14-digit number.
|
||||
|
||||
More information can be found at:
|
||||
http://bip.stat.gov.pl/en/regon/
|
||||
http://www.stat.gov.pl/bip/regon_ENG_HTML.htm
|
||||
https://wyszukiwarkaregon.stat.gov.pl/appBIR/index.aspx
|
||||
|
||||
>>> validate('192598184')
|
||||
'192598184'
|
||||
>>> validate('123456785')
|
||||
'123456785'
|
||||
>>> validate('192598183')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
InvalidChecksum: ...
|
||||
>>> validate('12345678512347')
|
||||
'12345678512347'
|
||||
>>> validate('12345678612342') # first check digit invalid
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
InvalidChecksum: ...
|
||||
>>> validate('12345678512348') # last check digit invalid
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
InvalidChecksum: ...
|
||||
"""
|
||||
|
||||
from stdnum.exceptions import *
|
||||
from stdnum.util import clean
|
||||
|
||||
|
||||
def compact(number):
|
||||
"""Convert the number to the minimal representation. This strips the
|
||||
number of any valid separators and removes surrounding whitespace."""
|
||||
return clean(number, ' -').upper().strip()
|
||||
|
||||
|
||||
def calc_check_digit(number):
|
||||
"""Calculate the check digit for organisations. The number passed
|
||||
should not have the check digit included."""
|
||||
if len(number) == 8:
|
||||
weights = (8, 9, 2, 3, 4, 5, 6, 7)
|
||||
else:
|
||||
weights = (2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8)
|
||||
check = sum(w * int(n) for w, n in zip(weights, number))
|
||||
return str(check % 11 % 10)
|
||||
|
||||
|
||||
def validate(number):
|
||||
"""Checks to see if the number provided is a valid REGON number. This
|
||||
checks the length, formatting and check digit."""
|
||||
number = compact(number)
|
||||
if not number.isdigit():
|
||||
raise InvalidFormat()
|
||||
if len(number) not in (9, 14):
|
||||
raise InvalidLength()
|
||||
if number[-1] != calc_check_digit(number[:-1]):
|
||||
raise InvalidChecksum()
|
||||
if len(number) == 14 and number[8] != calc_check_digit(number[:8]):
|
||||
raise InvalidChecksum()
|
||||
return 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."""
|
||||
try:
|
||||
return bool(validate(number))
|
||||
except ValidationError:
|
||||
return False
|
||||
Loading…
Add table
Add a link
Reference in a new issue