-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialization.py
730 lines (639 loc) · 27.9 KB
/
serialization.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
"""
Сериализция основных блоков мп - xmk\n
Основные блоки:\n
Титульный лист,\n
Исходные данные,\n
Средства об измерениях,\n
Сведения об обрузуемых зу и их частях,\n
Сведения об уточняемом учатске и частях,\n
Сведения об измененных учасках и их частях,\n
Единое землепользование,\n
Сведения о земельных участках, посредством которых обеспечивается доступ,\n
Заключение кадастрового инженера \n
"""
from serialization.basic import *
from utils.xsd import value_from_xsd
from datetime import datetime
# import logging
# from logging.config import fileConfig
# fileConfig('loggers/logging_config.ini')
# logger = logging.getLogger()
def test():
"""
test
"""
print("sdfasdf")
class XmlTitleDict:
"""
Формированяи словаря для титульника
"""
def __init__(self, node):
"""
:param node: GeneralCadastralWorks
"""
self.node = node
self.contractor = None
def __children_dict(self, node, *args):
"""
:param node: Contractor/child
:return: dict (node.tag : node.text)
"""
res = dict()
for el in node:
res[el.tag] = el.text
return res
def __contractor(self):
if not self.contractor:
return self.__children_dict(self.node.xpath('Contractor/child::*'))
return self.contractor
def __xml_reason_to_text(self):
return ''.join(self.node.xpath('Reason/text()'))
def __xml_purpose_to_text(self):
return ''.join(self.node.xpath('Purpose/text()'))
def __xml_client_to_text(self):
return ' '.join(self.node.xpath('Clients/*[1]/child::*/node()/text()'))
def __xml_contrsactor_fio_to_text(self):
_ = self.__contractor()
if _:
return f"{_.get('FamilyName', '')} " \
f"{_.get('FirstName', '')} " \
f"{_.get('Patronymic', '')}"
return ''
def __xml_ncertificate_to_text(self):
_ = self.__contractor()
if _:
return _.get('NCertificate', '')
return ''
def __xml_telefon_to_text(self):
_ = self.__contractor()
if _:
return _.get('Telephone', '')
return ''
def __xml_email_to_text(self):
_ = self.__contractor()
if _:
return _.get('Email', '')
return ''
def __xml_address_to_text(self):
_ = self.__contractor()
if _:
return _.get('Address', '')
return ''
def __xml_organization_to_text(self):
return ' '.join(self.node.xpath('Contractor/Organization/node()/text()'))
def __xml_data_to_text(self):
_dt = datetime.strptime(dict(self.node.attrib).get('DateCadastral'), "%Y-%m-%d")
if _dt:
# return f"""{_dt:%d.%m.%Y}"""
pass
return ''
def to_dict(self):
"""
Данный метод возвращает словарь значения для заполнения шаблона title.docx
:return: dict->cnfg.Title
"""
result = None
try:
value_title = [self.__xml_reason_to_text(), self.__xml_purpose_to_text(),
self.__xml_client_to_text(), self.__xml_contrsactor_fio_to_text(),
self.__xml_ncertificate_to_text(), self.__xml_telefon_to_text(), self.__xml_address_to_text(),
self.__xml_email_to_text(), self.__xml_organization_to_text(), self.__xml_data_to_text()]
result = dict(zip(cnfg.TITLE.attr, value_title))
except Exception as e:
# logger.error(f""" Ошибки при формировании титульника {e} """)
pass
else:
# logger.info(f"""Словарь титульного {result}""")
pass
return result
class XmlSurveyDict(XMLElemenBase):
"""
Формирование словаря для Сведени о выполненных измерениях и расчетах\n
:param root: Survey
"""
pathListGeopointsOpred = 'GeopointsOpred/child::*'
pathTochAreaParcel = 'TochnAreaParcels/child::*'
pathTochGeopoitsParcels = 'TochnGeopointsParcels/child::*'
def __xml_geopoints_opred_to_list(self):
"""
:return: list (geopoint_opreds)
"""
el = self.node.xpath(self.pathListGeopointsOpred)
res = []
try:
for index, _ in enumerate(el):
_method = ''.join(_.xpath('Methods/child::*[name()="GeopointOpred"]/text()'))
method_val = value_from_xsd('/'.join([cnfg.PATH_XSD,cnfg.GEOPOINTS_OPRED.dict['geopointopred']]),_method)
res.append([str(index + 1),''.join(_.xpath('CadastralNumberDefinition/text()')), method_val])
except Exception as e:
logger.error(f"Ошибка при разборе {el}")
finally:
el.clear
return res
def __xml_toch_area_parcel_to_list(self):
el = self.node.xpath(self.pathTochAreaParcel)
res = []
try:
for index, _ in enumerate(el):
res.append([str(index + 1),
''.join(_.xpath('CadastralNumberDefinition/text()')),
''.join(_.xpath('Area/Area/text()')),
''.join(_.xpath('Formula/text()')),
])
finally:
el.clear()
return res
def __xml_toch_geopoints_parcel_to_list(self):
el = self.node.xpath(self.pathTochGeopoitsParcels)
res = []
try:
for index, _ in enumerate(el):
res.append([str(index + 1),
''.join(_.xpath('CadastralNumberDefinition/text()')),
''.join(_.xpath('Formula/text()')),
])
finally:
el.clear()
return res
def to_dict(self):
_res = None
try:
_res = {
cnfg.GEOPOINTS_OPRED.name: StaticMethod.merge_array_list(cnfg.GEOPOINTS_OPRED.attr,
self.__xml_geopoints_opred_to_list()),
cnfg.TOCHN_GEOPOINTS_PARCELS.name: StaticMethod.merge_array_list(cnfg.TOCHN_GEOPOINTS_PARCELS.attr,
self.__xml_toch_geopoints_parcel_to_list()),
cnfg.TOCHN_AREA_PARCELS.name: StaticMethod.merge_array_list(cnfg.TOCHN_AREA_PARCELS.attr,
self.__xml_toch_area_parcel_to_list())
}
except Exception as e:
# logger.error(f"""Ошибка в формировании словаря для средств измерений {e}""")
pass
else:
# logger.info(f"""Словарь для средст измерений готов {_res}""")
pass
return _res
class XmlInputDataDict(XMLElemenBase):
"""
формирование словаря Исхпдные данные\n
:param root == InputData
"""
NAME = 'Name'
NUMBER = 'Number'
DATE = 'Date'
pathListDocuments = 'Documents/child::*'
pathGeodesicBses = 'GeodesicBases/child::*'
pathMeansSurveys = 'MeansSurvey/child::*'
pathObjectsRealty = 'ObjectsRealty/child::*'
pathListSystemCood= '../CoordSystems/child::*/@Name'
def __xml_sys_coord_to_text(self):
return ''.join(self.node.xpath(self.pathListSystemCood))
def __xml_documents_to_list(self):
el = self.node.xpath(self.pathListDocuments)
res = []
try:
for index, _ in enumerate(el):
_dt = datetime.strptime(''.join(_.xpath('Date/text()')),'%Y-%m-%d').strftime('%d.%m.%Y')
_tmp = f" № {''.join(_.xpath('Number/text()'))} от { _dt } г."
_name = ''.join(_.xpath('Name/text()'))
if not _name:
_name = StaticMethod.xml_key_to_text(_, 'CodeDocument/text()', cnfg.INPUT_DATA.dict['alldocuments'])
res.append([str(index + 1),_name,_tmp])
finally:
el.clear()
return res
def __xml_geodesic_bases_to_list(self):
el = self.node.xpath(self.pathGeodesicBses)
res = []
try:
for index, _ in enumerate(el):
_tmp = f"{''.join(_.xpath('PName/text()'))} {''.join(_.xpath('PKind/text()'))}"
res.append([str(index + 1), _tmp, ''.join(_.xpath('PKlass/text()')),
''.join(_.xpath('OrdX/text()')),
''.join(_.xpath('OrdY/text()'))])
finally:
el.clear()
return res
def __xml_means_surveys_to_list(self):
el = self.node.xpath(self.pathMeansSurveys)
res = []
try:
for index, _ in enumerate(el):
res.append([str(index + 1), ''.join(_.xpath('Name/text()')),
' '.join(_.xpath('Registration/child::*/text()')),
''.join(_.xpath('CertificateVerification/text()'))])
finally:
el.clear()
return res
def __xml_objects_realtys_to_list(self):
el = self.node.xpath(self.pathObjectsRealty)
res = list()
try:
for index, _ in enumerate(el):
res.append([str(index + 1),''.join(_.xpath('CadastralNumberParcel/text()')), ', '.join(_.xpath('InnerCadastralNumbers/child::*/text()'))])
# logging.info(f"""Сведения о наличии объектов недвижимости { res }""")
finally:
el.clear()
return res
def to_dict(self):
_res = None
try:
_res = {cnfg.INPUT_DATA.name: StaticMethod.merge_array_list(cnfg.INPUT_DATA.attr, self.__xml_documents_to_list()),
cnfg.SYSTEM_COORD: self.__xml_sys_coord_to_text(),
cnfg.GEODESIC_BASES.name: StaticMethod.merge_array_list(cnfg.GEODESIC_BASES.attr, self.__xml_geodesic_bases_to_list()),
cnfg.MEANS_SURVEY.name: StaticMethod.merge_array_list(cnfg.MEANS_SURVEY.attr, self.__xml_means_surveys_to_list()),
cnfg.OBJECTS_REALTY.name: StaticMethod.merge_array_list(cnfg.OBJECTS_REALTY.attr, self.__xml_objects_realtys_to_list())}
except Exception as e:
pass
# /logger.error(f"""Ошибка при формировании словаря Исходных данных {e}""")
else:
pass
# logger.info(f"""Словарь для исходных данных готов {_res}""")
return _res
class XmlParcel(XMLElemenBase):
def xml_cadnum_to_text(self):
_ = self.node.xpath('@Definition | @CadastralNumber | @NumberRecord')
if _:
return _[0]
return ''
"""
вспомогательный класс для обработки общих узлов участка\n
root in [NewParcel, SubParcels, ExistParcel, ChangeParcel ... все все остальные узлы с похожей структурой]
"""
def xml_subparcels_to_dict(self):
"""
:return: Словарь для частей
"""
res = dict()
xml_node_subparcels = self.node.xpath('SubParcels')
if xml_node_subparcels is not None and len(xml_node_subparcels) > 0:
subparcels = XmlSubParcels(xml_node_subparcels[0])
res = subparcels.to_dict()
del subparcels
return res
def xml_ordinates_to_dict(self):
"""
:return: Получить словарь коорлинат
"""
res = dict()
xml_ordinate = self.node.xpath('Contours | EntitySpatial')
if xml_ordinate is not None and len(xml_ordinate) > 0:
full_ord = XmlFullOrdinate(xml_ordinate[0], self.xml_cadnum_to_text())
res = {cnfg.ENTITY_SPATIAL.name: StaticMethod.merge_array_list(cnfg.ENTITY_SPATIAL.attr,
full_ord.full_ordinate()),
cnfg.BORDERS.name: StaticMethod.merge_array_list(cnfg.BORDERS.attr, full_ord.full_borders()),
}
del full_ord
return res
def __xml_owner_to_text(self, node):
"""
Преобразование правооблаталей
:param node: OwnerNeighbours
:return:
"""
res = ''
try:
for _ in node:
rows = ''.join(_.xpath('child::NameRight/text()'))
# rows += f""" {', '.join(_.xpath('child::OwnerNeighbour/NameOwner/text()'))}"""
# rows += f""" {', '.join(_.xpath('child::OwnerNeighbour/ContactAddress/text()'))}"""
# res += f"""{ rows }; """
finally:
node.clear()
return res
def xml_related_parcel_to_list(self):
"""
'attr': ['point', 'cadastralnumber', 'right']
:return: list сведений о смежниках участка
"""
_node = self.node.xpath('RelatedParcels/child::*')
res = []
try:
for _ in _node:
_rows = []
_rows.append(''.join(_.xpath('Definition/text()')))
_rows.append(', '.join(_.xpath('child::*/CadastralNumber/text()')))
_rows.append(self.__xml_owner_to_text(_.xpath('child::*/OwnerNeighbours')))
res.append(_rows)
finally:
_node.clear()
return res
class XmlNewParcel(XmlParcel):
"""
Преобразование участка на образование в словарь \n
:param root = NewParcel
"""
def __full_addres(self, node):
"""
Форимрование адрема
:param node: Address
:return: text
"""
region = list()
region = [StaticMethod.xml_key_to_text(node,'Region/text()', cnfg.PARCEL_COMMON.dict['address_code'])]
region.extend(node.xpath('District/@*')[::-1])
region.extend(node.xpath('City/@*')[::-1])
region.extend(node.xpath('UrbanDistrict/@*')[::-1])
region.extend(node.xpath('SovietVillage/@*')[::-1])
region.extend(node.xpath('Locality/@*')[::-1])
region.extend(node.xpath('Street/@*')[::-1])
region.extend(node.xpath('Level1/@*')[::-1])
region.extend(node.xpath('Level2/@*')[::-1])
region.extend(node.xpath('Apartment/@*')[::-1])
return ' '.join(region)
def __full_utilization(self, node):
"""
Формирование utilization
:param node: Utilization
:return:
"""
try:
res = ''
if 'ByDoc' in node.attrib:
res = node.attrib['ByDoc']
elif 'Utilization' in node.attrib:
res = StaticMethod.xml_key_to_text(node, '@Utilization', cnfg.PARCEL_COMMON.dict['utilization'])
elif 'LandUse' in node.attrib:
res = StaticMethod.xml_key_to_text(node, '@LandUse',cnfg.PARCEL_COMMON.dict['landuse'])
finally:
node.clear()
return res
def full_area(self, node):
"""
Преобразование площади
:param node: Area
:return: valua is the Area
"""
# result = f"""{''.join(node.xpath('Area/text()'))}±{''.join(node.xpath('Inaccuracy/text()'))}"""
node.clear()
return result
def full_contours_area(self, node):
"""
:param node: node = Contours
:return:
"""
_area = ' '
# if node and len(node) > 0:
# _xml_area = node[0].xpath("child::*/Area")
if node:
for index, _ in enumerate(node,1):
# _xml_area = _.xpath('Area')
# _area += f"""({index}) {self.full_area(_)} """
pass
return _area
def __xml_general_info_to_dict(self):
dict_address = dict()
xml_addrss = self.node.xpath('Address')
xml_category = self.node.xpath('Category')
xml_utilization = self.node.xpath('Utilization | LandUse')
if xml_addrss:
addres=xml_addrss[0]
dict_address['location_note'] = ''.join(addres.xpath("Other/text()"))
type_address = addres.xpath('@AddressOrLocation')[0]
text_address = self.__full_addres(addres)
if type_address == '1':
dict_address[cnfg.PARCEL_COMMON.address] = text_address
else:
dict_address['location'] = text_address
xml_addrss.clear()
if xml_category:
dict_address['category'] = StaticMethod.xml_key_to_text(xml_category[0],'@Category',
cnfg.PARCEL_COMMON.dict['categories'])
xml_category.clear()
if xml_utilization:
dict_address['utilization_landuse'] = self.__full_utilization(xml_utilization[0])
xml_utilization.clear()
xml_area = self.node.xpath('Area')
xml_area_contour = self.node.xpath('Contours/child::*/child::Area')
if xml_area:
dict_address['area'] = self.full_area(xml_area[0]) + '\n' + self.full_contours_area(xml_area_contour)
dict_address['min_area'] = ''.join(self.node.xpath('MinArea/Area/text()'))
dict_address['max_area'] = ''.join(self.node.xpath('MaxArea/Area/text()'))
dict_address['note'] = ''.join(self.node.xpath('Note/text()'))
dict_address['prevcadastralnumber'] = self.xml_object_realty_inner_cadastral_number_to_text()
return dict_address
def xml_object_realty_inner_cadastral_number_to_text(self):
return ', '.join(self.node.xpath('ObjectRealty/InnerCadastralNumbers/child::*/text()'))
def to_dict(self):
res = {cnfg.PARCEL_COMMON.cadnum: self.xml_cadnum_to_text(),
cnfg.RELATEDPARCELS.name: StaticMethod.merge_array_list(cnfg.RELATEDPARCELS.attr,
self.xml_related_parcel_to_list()),
}
res.update(self.__xml_general_info_to_dict())
res.update(self.xml_subparcels_to_dict())
res.update(self.xml_ordinates_to_dict())
return res
class XmlNewParcelProviding(XmlNewParcel):
"""
Сведения о участках посредством которых обеспечивается доступ
"""
def __get_context(self, node):
"""
:param node: ProvidingCadastralNumber
:return:
"""
re = node.xpath('child::*/text()')
re.extend(node.xpath('child::*/child::*/text()'))
return ', '.join(re)
def __xml_providin_to_list(self):
_ = self.node.xpath('//ProvidingPassCadastralNumbers')
res = []
try:
for i, el in enumerate(_,1):
_def = el.getparent().xpath('@Definition')
if not _def:
_def = el.getparent().xpath('@NumberRecord')
if not _def:
_def = el.getparent().xpath('@CadastralNumber')
_definition = ''.join(_def)
res.append([str(i), _definition, self.__get_context(el)])
finally:
_.clear()
return res
def to_dict(self):
res = {cnfg.PROVIDING.name: StaticMethod.merge_array_list(cnfg.PROVIDING.attr,
self.__xml_providin_to_list())
}
return res
class XmlExistParcel(XmlNewParcel):
"""
Фоомирования словаря значений для узлос SpecifyRelatedParcel | ExistParcels
"""
def __init__(self, node):
super(XmlExistParcel,self).__init__(node)
def xml_cadnum_to_text(self):
number_record = ''.join(self.node.xpath('@NumberRecord'))
str_number_record = ''
if number_record:
# str_number_record = f"""({number_record}"""
pass
# return f"""{ ''.join(self.node.xpath('@CadastralNumber'))} {str_number_record}"""
def __xml_delete_all_border_to_dict(self):
deleteAllBorder = self.node.xpath('DeleteAllBorder')
res = dict()
if deleteAllBorder:
try:
_ord = Ordinatre(self.node, CNST_EXISTPARCEL)
res = {
cnfg.ENTITY_SPATIAL_EXIST.name: StaticMethod.merge_array_list(cnfg.ENTITY_SPATIAL_EXIST.attr,
_ord.xml_exist_ordinate_to_list()),
cnfg.BORDERS.name: []
}
finally:
deleteAllBorder.clear()
return res
def __xml_all_border_to_dict(self):
allborder = self.node.xpath('AllBorder')
res = dict()
if allborder and len(allborder) > 0:
try:
xmlfull = XmlFullOrdinate(allborder[0].xpath('Contours | EntitySpatial')[0], self.xml_cadnum_to_text())
res = {cnfg.ENTITY_SPATIAL_EXIST.name: StaticMethod.merge_array_list(cnfg.ENTITY_SPATIAL_EXIST.attr,
xmlfull.full_ordinate()),
cnfg.BORDERS.name: StaticMethod.merge_array_list(cnfg.BORDERS.attr,
xmlfull.full_borders()),
}
del xmlfull
finally:
allborder.clear()
return res
def __xml_change_border_to_dict(self):
changeborder = self.node.xpath('ChangeBorder')
res = dict()
if changeborder:
try:
ordinate = Ordinatre(self.node, CNST_EXISTPARCEL)
res = {
cnfg.ENTITY_SPATIAL_EXIST.name: StaticMethod.merge_array_list(cnfg.ENTITY_SPATIAL_EXIST.attr,
ordinate.xml_exist_ordinate_to_list()),
cnfg.BORDERS.name: []
}
del ordinate
finally:
changeborder.clear()
return res
def __xml_contours_entity__to_dict(self):
res = dict()
xml_ordinate = self.node.xpath('Contours | EntitySpatial')
if xml_ordinate is not None and len(xml_ordinate) > 0:
full_ord = XmlFullOrdinate(xml_ordinate[0], self.xml_cadnum_to_text())
res = {cnfg.ENTITY_SPATIAL_EXIST.name: StaticMethod.merge_array_list(cnfg.ENTITY_SPATIAL_EXIST.attr,
full_ord.full_ordinate()),
cnfg.BORDERS.name: StaticMethod.merge_array_list(cnfg.BORDERS.attr, full_ord.full_borders()),
}
del full_ord
return res
def __full_ordinate_to_dict(self):
if self.node.xpath('AllBorder'):
return self.__xml_all_border_to_dict()
elif self.node.xpath('ChangeBorder'):
return self.__xml_change_border_to_dict()
elif self.node.xpath('DeleteAllBorder'):
return self.__xml_change_border_to_dict()
else:
return self.__xml_contours_entity__to_dict()
def __xml_ordinate_borders_to_dict(self):
res = {
cnfg.RELATEDPARCELS.name: StaticMethod.merge_array_list(cnfg.RELATEDPARCELS.attr,
self.xml_related_parcel_to_list())
}
res.update(self.__full_ordinate_to_dict())
return res
def __xml_exist___general_info(self):
res_dict = dict()
xml_area = self.node.xpath('Area')
xml_area_contour = self.node.xpath('Contours/child::*/child::Area')
if xml_area:
res_dict[cnfg.PARCEL_COMMON.area] = self.full_area(xml_area[0]) + '\n' + self.full_contours_area(xml_area_contour)
area_gkn = self.node.xpath('AreaInGKN/text()')
if area_gkn:
res_dict[cnfg.PARCEL_COMMON.areaGKN]= area_gkn[0]
delta = self.node.xpath('DeltaArea/text()')
if delta:
res_dict[cnfg.PARCEL_COMMON.deltaArea]= delta[0]
min_area = self.node.xpath('MinArea')
if min_area:
res_dict[cnfg.PARCEL_COMMON.min_area]= self.full_area(min_area[0])
max_area = self.node.xpath('MaxArea')
if max_area:
res_dict[cnfg.PARCEL_COMMON.max_area]= self.full_area(max_area[0])
res_dict[cnfg.PARCEL_COMMON.prevcadastralnumber] = self.xml_object_realty_inner_cadastral_number_to_text()
note= self.node.xpath('Note/text()')
if note:
res_dict[cnfg.PARCEL_COMMON.note]= note[0]
return res_dict
def to_dict(self):
res = {cnfg.PARCEL_COMMON.cadnum: self.xml_cadnum_to_text()}
res.update(self.__xml_exist___general_info())
res.update(self.__xml_ordinate_borders_to_dict())
res.update(self.xml_subparcels_to_dict())
return res
class XmlSubParcels:
"""
Формирования словаря значений для частей \n
node: SubParcels
"""
def __init__(self, node):
super(XmlSubParcels, self).__init__()
self.node = node
def __del__(self):
self.node.clear()
def __xml_sub_parcels_dict(self):
node = self.node.xpath('child::*[name()="NewSubParcel" or name()="ExistSubParcel"]')
entity_spatial = []
entity_spatial_ex = []
general = []
try:
for index, _ in enumerate(node):
subParcel = ElementSubParcel(_)
if subParcel.type_ordinate == CNST_NEWPARCEL:
entity_spatial.append(subParcel.xml_new_dict())
else:
entity_spatial_ex.append(subParcel.xml_ext_dict())
general.append(subParcel.xml_general_dict(index+1))
del subParcel
finally:
self.node.clear()
return {cnfg.SUB_FULL_ORDINATE.name: entity_spatial,
cnfg.SUB_EX_FULL_ORDINATE.name: entity_spatial_ex,
cnfg.SUBPARCEL_GENERAL.name: general}
def to_dict(self):
res = {cnfg.SUBPARCEL_ROWS.cadnum: ''.join(self.node.xpath('CadastralNumberParcel/text()')),
}
res.update(self.__xml_sub_parcels_dict())
return res
class XmlChangeParcel(XmlNewParcel):
"""
Формирования словаря данных для ChangeParcel(измененный участок)
"""
def __xml_delete_entry_parcels(self):
res = ''
_ = self.node.xpath('DeleteEntryParcels/child::*/@*')
if _:
res = ', '.join(_)
_.clear()
return res
def _xml_transform_entry_parcels(self):
res = ''
_ = self.node.xpath('TransformationEntryParcels/child::*/@*')
if _:
res = ', '.join(_)
_.clear()
return res
def to_dict(self):
res = {cnfg.CHANGEPARCELS.cadnum: self.xml_cadnum_to_text(),
cnfg.CHANGEPARCELS.deleteEntyParcel: self.__xml_delete_entry_parcels(),
cnfg.CHANGEPARCELS.transformEntryParcel: self._xml_transform_entry_parcels(),
cnfg.CHANGEPARCELS.innerCadNum: self.xml_object_realty_inner_cadastral_number_to_text(),
cnfg.CHANGEPARCELS.note: ''.join(self.node.xpath('Note/text()')),
}
res.update(self.xml_subparcels_to_dict())
return res
class XmlConclusion(XMLElemenBase):
"""
Чтоб не отходит от фрмата - )) - > заключение кадастрового инженера
"""
def to_dict(self):
return {
cnfg.CONCLUSION['name']: self.node.text
}