Skip to content

Commit

Permalink
HH Data Importer: MPAN map from and to
Browse files Browse the repository at this point in the history
  • Loading branch information
tlocke committed Dec 4, 2024
1 parent e1e21dd commit fb31ed9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
22 changes: 12 additions & 10 deletions chellow/e/hh_parser_df2.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ def __next__(self):
if lline.startswith("#O"):
outstation_parts = lline[2:].split("-")
self.core = parse_mpan_core(outstation_parts[0])
if self.core in self.mpan_map and self.mpan_map[self.core] is None:
msg = f"The MPAN core {self.core} has been ignored"
if len(self.messages) == 0 or self.messages[-1] != msg:
self.messages.append(
f"The MPAN core {self.core} has been ignored"
)
self.core = None
continue

elif lline.startswith("#S"):
sensor = int(lline[2:].strip())
Expand Down Expand Up @@ -87,8 +79,18 @@ def __next__(self):
raise BadRequest("Problem parsing the value: " + fields[2])
status = fields[3][-1]

if self.core is None:
continue
if self.core in self.mpan_map:
mapping = self.mpan_map[self.core]
if mapping["from"] <= start_date <= mapping["to"]:
self.core = mapping["mpan"]

if self.core is None:
msg = f"The MPAN core {self.core} has been ignored"
if len(self.messages) == 0 or self.messages[-1] != msg:
self.messages.append(
f"The MPAN core {self.core} has been ignored"
)
continue

local_datum = {
"mpan_core": self.core,
Expand Down
13 changes: 11 additions & 2 deletions chellow/templates/e/dc_contract_properties_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@ <h4>Example</h4>
"private_key": "private_key", /* Remove if using password */
"directories": ["downloads1", "downloads2"],
"mpan_map": { /* Optional */
"99 0993 2821 985": null, /* Ignore MPAN */
},
"99 0993 2821 985": {
"mpan": null, /* Ignore MPAN */
"from": 2024-12-04T10:00:00Z,
"to": 2025-01-12:00:00Z,
},
"99 0873 1942 952": {
"mpan": "99 7821 8541 389",
"from": 2024-11-16T22:00:00Z,
"to": 2025-02-18:00:00Z,
},
},
}
</pre>
</code>
Expand Down

0 comments on commit fb31ed9

Please sign in to comment.