mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
preparing for data extraction
This commit is contained in:
parent
c9d3bb6eec
commit
7b04e1edc7
1 changed files with 9 additions and 18 deletions
|
|
@ -44,8 +44,8 @@ def get_house_number(address: str) -> str | None:
|
||||||
|
|
||||||
|
|
||||||
class XmlParser:
|
class XmlParser:
|
||||||
epc = None
|
epc = {}
|
||||||
additional_data = None
|
additional_data = {}
|
||||||
uprn = None
|
uprn = None
|
||||||
|
|
||||||
# heating/emissions information
|
# heating/emissions information
|
||||||
|
|
@ -72,12 +72,6 @@ class XmlParser:
|
||||||
|
|
||||||
floor_dimensions = None
|
floor_dimensions = None
|
||||||
|
|
||||||
# The value of the URPN tells us about the file type that we're parsing
|
|
||||||
UPRN_FILETYPE_MAP = {
|
|
||||||
0: "EPR",
|
|
||||||
-1: "RDSAP_EPR"
|
|
||||||
}
|
|
||||||
|
|
||||||
RATINGS_MAP = {
|
RATINGS_MAP = {
|
||||||
"0": "N/A",
|
"0": "N/A",
|
||||||
"1": "Very Poor",
|
"1": "Very Poor",
|
||||||
|
|
@ -122,14 +116,11 @@ class XmlParser:
|
||||||
self.filekey = filekey
|
self.filekey = filekey
|
||||||
self.surveyor_company = surveyor_company
|
self.surveyor_company = surveyor_company
|
||||||
|
|
||||||
# The xml parser is use to parse the EPC and EPR xmls and different file types will contain different
|
# We check if we have a lig xml or rdsap xml
|
||||||
# information
|
# We look for the presence of the Schema-Version-Original tag
|
||||||
# In order to identify the file type, we can look for the presence of the 'UPRN' tag
|
self.is_lig = len(self.xml.getElementsByTagName("Schema-Version-Original")) > 0
|
||||||
# If the UPRN tag is present, we can assume that the file is an EPC
|
|
||||||
# If the UPRN tag is not present, we can assume that the file is an EPR
|
|
||||||
self.get_uprn(uprn)
|
|
||||||
|
|
||||||
self.file_type = self.UPRN_FILETYPE_MAP.get(self.uprn, "EPC")
|
self.get_uprn(uprn)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_node(node):
|
def get_node(node):
|
||||||
|
|
@ -145,10 +136,10 @@ class XmlParser:
|
||||||
return node_first_child.nodeValue
|
return node_first_child.nodeValue
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.file_type == "RDSAP_EPR":
|
|
||||||
# This file type contains just limited information compared to a regular EPR/EPC, and so we just exit
|
if not self.is_lig:
|
||||||
# unless we learn something else that determines that we need information from this file
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self.get_assessor_details()
|
self.get_assessor_details()
|
||||||
|
|
||||||
self.get_heating_and_emissions_data()
|
self.get_heating_and_emissions_data()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue