-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
executable file
·146 lines (121 loc) · 3.69 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env python3
from zeep import Client, Settings
from zeep.cache import SqliteCache
from zeep.transports import Transport
from zeep.wsse.username import UsernameToken
import sys
TRIAL = True
LVID = 310
KUID = '693936'
PS = [
[KUID, '76', '2'],
[KUID, '41', '1'],
[KUID, '104', ''],
[KUID, '127', ''],
[KUID, '129', ''],
[KUID, '130', ''],
[KUID, '1191', ''],
[KUID, '1192', ''],
[KUID, '1362', ''],
[KUID, '1385', '8'],
[KUID, '1385', '9'],
[KUID, '1385', '11'],
[KUID, '2275', '1'],
]
PIDS = [
2850900306,
2850879306,
2850920306,
62570648010,
62570653010,
62570658010,
3168567306,
3168568306,
2851102306,
3370798306,
3370799306,
3370801306,
2851326306,
]
trialWsdls = {
"vyhledat": "https://wsdptrial.cuzk.cz/trial/dokumentace/ws28/wsdp/vyhledat_v28.wsdl",
"informace": "https://wsdptrial.cuzk.cz/trial/dokumentace/ws28/wsdp/informace_v28.wsdl",
"sestavy": "https://wsdptrial.cuzk.cz/trial/dokumentace/ws28/wsdp/sestavy_v28.wsdl",
"ciselnik": "https://wsdptrial.cuzk.cz/trial/dokumentace/ws28/wsdp/ciselnik_v28.wsdl",
"ctios": "https://wsdptrial.cuzk.cz/trial/dokumentace/ws28/ctios/ctios_v28.wsdl",
"ucet": "https://wsdptrial.cuzk.cz/trial/dokumentace/ws28/wsdp/ucet_v28.wsdl",
}
prodWsdls = {
"sestavy": "https://katastr.cuzk.cz/dokumentace/ws28/wsdp/sestavy_v28.wsdl",
"ciselnik": "https://katastr.cuzk.cz/dokumentace/ws28/wsdp/ciselnik_v28.wsdl",
"vyhledat": "https://katastr.cuzk.cz/dokumentace/ws28/wsdp/vyhledat_v28.wsdl",
"informace": "https://katastr.cuzk.cz/dokumentace/ws28/wsdp/informace_v28.wsdl",
"ucet": "https://katastr.cuzk.cz/dokumentace/ws28/wsdp/ucet_v28.wsdl",
"ctios": "https://katastr.cuzk.cz/dokumentace/ws28/wsdp/ctios_v28.wsdl",
}
def CUZKClient(wsdl):
transport = Transport(cache=SqliteCache())
settings = Settings(raw_response=False, strict=False, xml_huge_tree=True)
settings = Settings(strict=False, xml_huge_tree=True)
relevantWsdls = prodWsdls
creds = None
if TRIAL:
relevantWsdls = trialWsdls
creds = ["WSTESTO", "WSHESLOO"]
if not creds[0] and not creds[1]:
print("Nastavte creds ve funkci CUZKClient")
sys.exit(0)
return Client(relevantWsdls[wsdl],
transport=transport,
wsse=UsernameToken(*creds),
settings=settings,
)
def parArgs(kuk, kc, pd):
args = {
"katastrUzemiKod": kuk,
"kmenoveCislo": kc,
}
if pd:
args['poddeleni'] = pd
return args
####### OPS
def mbrp(pid):
c = CUZKClient("informace")
resp = c.service.dejMBRParcel(pid)
return resp
def gip(kuk, kc, pd):
args = parArgs(kuk,kc,pd)
args['format'] = 'xml'
return CUZKClient("sestavy").service.generujInfoOParcelach(**args)
def pp(kuk, kc, pd):
args = parArgs(kuk,kc,pd)
return CUZKClient("vyhledat").service.najdiParcelu(**args)
###### tests
def test_pp():
for p in PS:
r = pp(p[0], p[1], p[2])
#print(r['ParcelaList']['Parcela'][0]['idParcely'])
print(r)
def test_mbrp():
p = PIDS[3]
r = mbrp(p)
print(r)
clvs = [
310, 17, 28, 44, 266, 307, 73, 360, 361, 138, 38, 314, 326, 168, 226, 349, 348, 344,
359, 38, 33, 139, 315,
]
if __name__ == "__main__":
#r = gip(*PS[4])
#print(r)
#test_pp()
#test_mbrp()
#for c in clvs:
print(CUZKClient("informace").service.dejNahledLV(katuzeKod=KUID, lvCislo=clvs[0]))
#print(CUZKClient("sestavy").service.generujLVZjednodusene(
# lvCislo=clvs[0],
# katastrUzemiKod=KUID,
# format='xml',
#))
#dom = xml.dom.minidom.parseString(out)
#print(dom.toprettyxml())
#print(out)