Skip to content

Commit e26696a

Browse files
committed
Porting code to Python 3.
1 parent 8c91f5e commit e26696a

File tree

8 files changed

+88
-83
lines changed

8 files changed

+88
-83
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on-line validations of Polish and EU companies. Please, visit our web page for m
1010

1111
The documentation and samples are available at https://nip24.pl/dokumentacja/
1212

13+
# Version
14+
15+
Version 1.3.3 is the last version compatible with Python 2.7 and is available for download here: https://github.com/nip24pl/nip24-python-client/releases/tag/1.3.3
16+
Begining from version 1.3.4 only Python 3.7 and newer is supported.
17+
1318
# License
1419

1520
This project is delivered under Apache License, Version 2.0:

example.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -41,65 +41,65 @@
4141
if account:
4242
pprint(vars(account))
4343
else:
44-
print u'Błąd: ' + nip24.getLastError()
44+
print('Błąd: ' + nip24.getLastError())
4545

4646
# Sprawdzenie statusu fimy
4747
active = nip24.isActiveExt(Number.NIP, nip)
4848

4949
if active:
50-
print u'Firma prowadzi aktywną działalność'
50+
print('Firma prowadzi aktywną działalność')
5151
else:
5252
if not nip24.getLastError():
53-
print u'Firma zawiesiła lub zakończyła działalność'
53+
print('Firma zawiesiła lub zakończyła działalność')
5454
else:
55-
print u'Błąd: ' + nip24.getLastError()
55+
print('Błąd: ' + nip24.getLastError())
5656

5757
# Sprawdzenie statusu firmy w rejestrze VAT
5858
vat = nip24.getVATStatusExt(Number.NIP, nip, True)
5959

6060
if vat:
61-
print u'NIP: ' + vat.nip
62-
print u'REGON: ' + vat.regon
63-
print u'Nazwa firmy: ' + vat.name
64-
print u'Status: ' + str(vat.status)
65-
print u'Wynik: ' + vat.result
66-
print u'Data sprawdzenia: ' + vat.date.strftime('%Y-%m-%d')
67-
print u'Źródło: ' + vat.source
61+
print('NIP: ' + vat.nip)
62+
print('REGON: ' + vat.regon)
63+
print('Nazwa firmy: ' + vat.name)
64+
print('Status: ' + str(vat.status))
65+
print('Wynik: ' + vat.result)
66+
print('Data sprawdzenia: ' + vat.date.strftime('%Y-%m-%d'))
67+
print('Źródło: ' + vat.source)
6868
else:
69-
print u'Błąd: ' + nip24.getLastError()
69+
print('Błąd: ' + nip24.getLastError())
7070

7171
# Wywołanie metody zwracającej dane do faktury
7272
invoice = nip24.getInvoiceDataExt(Number.NIP, nip, False)
7373

7474
if invoice:
75-
print u'Nazwa: ' + invoice.name
76-
print u'Imię i nazwisko: ' + invoice.firstname + ' ' + invoice.lastname
77-
print u'Adres: ' + invoice.postCode + ' ' + invoice.postCity + ' ' + invoice.street \
78-
+ ' ' + invoice.streetNumber
79-
print u'NIP: ' + invoice.nip
75+
print('Nazwa: ' + invoice.name)
76+
print('Imię i nazwisko: ' + invoice.firstname + ' ' + invoice.lastname)
77+
print('Adres: ' + invoice.postCode + ' ' + invoice.postCity + ' ' + invoice.street
78+
+ ' ' + invoice.streetNumber)
79+
print('NIP: ' + invoice.nip)
8080
else:
81-
print u'Błąd: ' + nip24.getLastError()
81+
print('Błąd: ' + nip24.getLastError())
8282

8383
# Wywołanie metody zwracającej szczegółowe dane firmy
8484
all = nip24.getAllDataExt(Number.NIP, nip, False)
8585

8686
if all:
8787
pprint(vars(all))
8888
else:
89-
print u'Błąd: ' + nip24.getLastError()
89+
print('Błąd: ' + nip24.getLastError())
9090

9191
# Wywołanie metody zwracającej dane z systemu VIES
9292
vies = nip24.getVIESData(nip_eu)
9393

9494
if vies:
9595
pprint(vars(vies))
9696
else:
97-
print u'Błąd: ' + nip24.getLastError()
97+
print('Błąd: ' + nip24.getLastError())
9898

9999
# Wywołanie metody zwracającej informacje o rachunku bankowym
100100
iban = nip24.getIBANStatusExt(Number.NIP, nip, account_number)
101101

102102
if iban:
103103
pprint(vars(iban))
104104
else:
105-
print u'Błąd: ' + nip24.getLastError()
105+
print('Błąd: ' + nip24.getLastError())

nip24/__init__.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
# @license http://www.apache.org/licenses/LICENSE-2.0
2121
#
2222

23-
from number import *
24-
from pkd import *
25-
from invoicedata import *
26-
from alldata import *
27-
from viesdata import *
28-
from vatstatus import *
29-
from ibanstatus import *
30-
from accountstatus import *
31-
from nip import *
32-
from regon import *
33-
from krs import *
34-
from euvat import *
35-
from iban import *
36-
from nip24client import *
23+
from nip24.number import *
24+
from nip24.pkd import *
25+
from nip24.invoicedata import *
26+
from nip24.alldata import *
27+
from nip24.viesdata import *
28+
from nip24.vatstatus import *
29+
from nip24.ibanstatus import *
30+
from nip24.accountstatus import *
31+
from nip24.nip import *
32+
from nip24.regon import *
33+
from nip24.krs import *
34+
from nip24.euvat import *
35+
from nip24.iban import *
36+
from nip24.nip24client import *
3737

38-
__version__ = '1.3.3'
38+
__version__ = '1.3.4'

nip24/euvat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def normalize(nip):
4444
if not nip:
4545
return False
4646

47-
nip = nip.strip().translate(None, '-').translate(None, ' ').upper()
47+
nip = re.sub('[ -]', '', nip).upper()
4848

4949
if not re.match('[A-Z]{2}[A-Z0-9]{2,12}', nip):
5050
return False

nip24/iban.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def normalize(iban):
4343
if not iban:
4444
return False
4545

46-
iban = iban.strip().translate(None, '-').translate(None, ' ').upper()
46+
iban = re.sub('[ -]', '', iban).upper()
4747

4848
if not re.match('[A-Z]{2}[0-9A-Z]{13,30}', iban):
4949
return False

nip24/nip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def normalize(nip):
4242
if not nip:
4343
return False
4444

45-
nip = nip.strip().translate(None, '-')
45+
nip = re.sub('[ -]', '', nip).upper()
4646

4747
if not re.match('[0-9]{10}', nip):
4848
return False

0 commit comments

Comments
 (0)