chellow 1707396281.0.0__py3-none-any.whl → 1707995667.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of chellow might be problematic. Click here for more details.

chellow/e/hh_importer.py CHANGED
@@ -48,6 +48,7 @@ class HhDataImportProcess(threading.Thread):
48
48
  super().__init__(name=f"HH Manual Import: contract {dc_contract_id}")
49
49
 
50
50
  self.messages = []
51
+ self.error = None
51
52
  self.istream = istream
52
53
  self.dc_contract_id = dc_contract_id
53
54
  self.id = process_id
@@ -74,14 +75,16 @@ class HhDataImportProcess(threading.Thread):
74
75
  parser_module = importlib.import_module(
75
76
  f"chellow.e.hh_parser_{mod_name}"
76
77
  )
77
- self.converter = parser_module.create_parser(self.istream, mpan_map)
78
+ self.converter = parser_module.create_parser(
79
+ self.istream, mpan_map, self.messages
80
+ )
78
81
  sess.rollback()
79
82
  HhDatum.insert(sess, self.converter, contract)
80
83
  sess.commit()
81
84
  except BadRequest as e:
82
- self.messages.append(e.description)
85
+ self.error = e.description
83
86
  except BaseException:
84
- self.messages.append(f"Outer problem {traceback.format_exc()}")
87
+ self.error = f"Outer problem {traceback.format_exc()}"
85
88
 
86
89
  def get_status(self):
87
90
  return (
@@ -281,8 +284,8 @@ class HhImportTask(threading.Thread):
281
284
  for message in self.importer.messages:
282
285
  self.log(message)
283
286
 
284
- if len(self.importer.messages) > 0:
285
- raise BadRequest("Problem loading file.")
287
+ if self.importer.error is not None:
288
+ raise BadRequest(f"Problem loading file. {self.importer.error}")
286
289
 
287
290
  contract = Contract.get_dc_by_id(sess, self.contract_id)
288
291
  contract.update_state(state)
@@ -384,12 +387,12 @@ class HhImportTask(threading.Thread):
384
387
 
385
388
  self.importer.run()
386
389
  messages = self.importer.messages
387
- self.importer = None
388
390
  for message in messages:
389
391
  self.log(message)
390
392
 
391
- if len(messages) > 0:
392
- raise BadRequest("Problem loading file.")
393
+ if self.importer.error is not None:
394
+ raise BadRequest(f"Problem loading file. {self.importer.error}")
395
+ self.importer = None
393
396
 
394
397
  contract = Contract.get_dc_by_id(sess, self.contract_id)
395
398
  contract.update_state(state)
@@ -8,12 +8,12 @@ from werkzeug.exceptions import BadRequest
8
8
  from chellow.utils import parse_mpan_core, utc_datetime
9
9
 
10
10
 
11
- def create_parser(reader, mpan_map):
12
- return HhParserBglobal(reader, mpan_map)
11
+ def create_parser(reader, mpan_map, messages):
12
+ return HhParserBglobal(reader, mpan_map, messages)
13
13
 
14
14
 
15
15
  class HhParserBglobal:
16
- def __init__(self, reader, mpan_map):
16
+ def __init__(self, reader, mpan_map, messages):
17
17
  self.shredder = zip(itertools.count(1), csv.reader(reader))
18
18
  self.line_number, self.values = next(self.shredder)
19
19
  self.mpan_map = mpan_map
@@ -6,12 +6,12 @@ from werkzeug.exceptions import BadRequest
6
6
  from chellow.utils import HH, parse_mpan_core, utc_datetime
7
7
 
8
8
 
9
- def create_parser(reader, mpan_map):
10
- return StarkDf2HhParser(reader, mpan_map)
9
+ def create_parser(reader, mpan_map, messages):
10
+ return StarkDf2HhParser(reader, mpan_map, messages)
11
11
 
12
12
 
13
13
  class StarkDf2HhParser:
14
- def __init__(self, reader, mpan_map):
14
+ def __init__(self, reader, mpan_map, messages):
15
15
  self.line = self.line_number = None
16
16
  self.reader = zip(itertools.count(1), reader)
17
17
 
@@ -25,6 +25,9 @@ class StarkDf2HhParser:
25
25
  4: "REACTIVE_EXP",
26
26
  }
27
27
 
28
+ self.mpan_map = mpan_map
29
+ self.messages = messages
30
+
28
31
  def __iter__(self):
29
32
  return self
30
33
 
@@ -36,6 +39,15 @@ class StarkDf2HhParser:
36
39
  lline = self.line.strip().upper()
37
40
  if lline.startswith("#O"):
38
41
  self.core = parse_mpan_core(lline[2:])
42
+ if self.core in self.mpan_map and self.mpan_map[self.core] is None:
43
+ msg = f"The MPAN core {self.core} has been ignored"
44
+ if len(self.messages) == 0 or self.messages[-1] != msg:
45
+ self.messages.append(
46
+ f"The MPAN core {self.core} has been ignored"
47
+ )
48
+ self.core = None
49
+ continue
50
+
39
51
  elif lline.startswith("#S"):
40
52
  sensor = int(lline[2:].strip())
41
53
  try:
@@ -72,6 +84,10 @@ class StarkDf2HhParser:
72
84
  except ValueError:
73
85
  raise BadRequest("Problem parsing the value: " + fields[2])
74
86
  status = fields[3][-1]
87
+
88
+ if self.core is None:
89
+ continue
90
+
75
91
  local_datum = {
76
92
  "mpan_core": self.core,
77
93
  "channel_type": self.channel_type,
@@ -8,12 +8,12 @@ from werkzeug.exceptions import BadRequest
8
8
  from chellow.utils import parse_channel_type, parse_mpan_core, to_utc, validate_hh_start
9
9
 
10
10
 
11
- def create_parser(reader, mpan_map):
12
- return HhParserCsvSimple(reader, mpan_map)
11
+ def create_parser(reader, mpan_map, messages):
12
+ return HhParserCsvSimple(reader, mpan_map, messages)
13
13
 
14
14
 
15
15
  class HhParserCsvSimple:
16
- def __init__(self, reader, mpan_map):
16
+ def __init__(self, reader, mpan_map, messages):
17
17
  self.shredder = zip(itertools.count(1), csv.reader(reader))
18
18
  next(self.shredder) # skip the title line
19
19
  self.values = None
@@ -62,7 +62,11 @@
62
62
  "hostname": "example.com",
63
63
  "username": "username",
64
64
  "password": "password",
65
- "directories": ["downloads1", "downloads2"]}
65
+ "directories": ["downloads1", "downloads2"]
66
+ "mpan_map": { \\ Optional
67
+ "99 0993 2821 985": null, \\ Ignore MPAN
68
+ },
69
+ }
66
70
  </pre>
67
71
  </code>
68
72
  <p>For the HTTPS protocol:</p>
@@ -81,6 +85,9 @@
81
85
  "name2": val2,
82
86
  }
83
87
  }
88
+ "mpan_map": { \\ Optional
89
+ "99 0993 2821 985": null, \\ Ignore MPAN
90
+ },
84
91
  }
85
92
 
86
93
  {% endraw %}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chellow
3
- Version: 1707396281.0.0
3
+ Version: 1707995667.0.0
4
4
  Summary: Web Application for checking UK energy bills.
5
5
  Project-URL: Homepage, https://github.com/WessexWater/chellow
6
6
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
@@ -24,10 +24,10 @@ chellow/e/dno_rate_parser.py,sha256=5MYEbcYngh7n6Szn2h9zLTwQKXH-WHKy6c80PYwNLLQ,
24
24
  chellow/e/duos.py,sha256=ISTcNqe9KNjVNM2Qs8IBoQxnmSXOt5W_G7tZxp4T78M,28870
25
25
  chellow/e/elexon.py,sha256=s8QdLUQMeylLhghxvvhLyOL3-0ifUnMfmo3vcbot_DY,5487
26
26
  chellow/e/energy_management.py,sha256=aXC2qlGt3FAODlNl_frWzVYAQrJLP8FFOiNX3m-QE_Y,12388
27
- chellow/e/hh_importer.py,sha256=G1CK3AQQuJaNXCxGEY3UU_CjqOzfVZT-PDR67b3zpA0,20362
28
- chellow/e/hh_parser_bg_csv.py,sha256=IOjM-QliKzvSXyhslmxz504XWnsGkVKEaCQ48SNeNeQ,2423
29
- chellow/e/hh_parser_df2.py,sha256=G4kt4N4mNjUa1Z7B1Ov6rAyZmWDyGEVFYscdghToMRo,3558
30
- chellow/e/hh_parser_simple_csv.py,sha256=lVRprIEjDpTQdeXm2xcLmRAyre2LWec8ueVwcCISZPo,2082
27
+ chellow/e/hh_importer.py,sha256=nhmlWDNBm8U4salBud8ivdaDGF1lkY82NqQCrGuPYRI,20483
28
+ chellow/e/hh_parser_bg_csv.py,sha256=W5SU2MSpa8BGA0VJw1JXF-IwbCNLFy8fe35yxLZ7gEw,2453
29
+ chellow/e/hh_parser_df2.py,sha256=ynNNRMpLm9qs23tJjfm0vGSaAduXfPMw_7-WfQHXliQ,4209
30
+ chellow/e/hh_parser_simple_csv.py,sha256=RN4QOLvTQeoPrpvXvQ9hkOBZnR5piybLfjCiSJdjpjs,2112
31
31
  chellow/e/laf_import.py,sha256=aqkcbjnvfBPszBLSNg6getP7iW1uWiTVHy6N5Z5x39U,5514
32
32
  chellow/e/lcc.py,sha256=q5iGbeYZdnozkIdbGuxXoJO-1KDO7AHqYOXEGBIaNHI,4963
33
33
  chellow/e/mdd_importer.py,sha256=9GN-at0DC3vOjd-0N2U856O3hInnjkMWWcRfxzQ5DjA,32042
@@ -186,7 +186,7 @@ chellow/templates/e/dc_bill_edit.html,sha256=0GsN-ZIc4q-z_xs8igC2ZS6t4soo2SvB3qR
186
186
  chellow/templates/e/dc_bill_import.html,sha256=NHjMSoFizvFQIaPWuVE3nTCtMDTzJB0XmH8jXfV1tiA,2188
187
187
  chellow/templates/e/dc_bill_imports.html,sha256=lCaUR47r9KPr0VrQhEvVEaKexM5R_nmkxtzgpWZ0e9s,2135
188
188
  chellow/templates/e/dc_contract.html,sha256=_fq_s69kmbrGlScYngRYm4cPdRgh2roMvSfvG0J4xzA,2326
189
- chellow/templates/e/dc_contract_edit.html,sha256=BQPhcFqlBGaxBqinqxoeGZQPA6nmgfNAo9EcaOtycjM,2960
189
+ chellow/templates/e/dc_contract_edit.html,sha256=wKK2pXN78VfSJ6gjfNRkikRFkYTiKtGL3UeVFIYSRwc,3115
190
190
  chellow/templates/e/dc_contract_hh_import.html,sha256=UODiBFNohb60MjH1w-9JW1JE0O9GR2uKPGw-lD7Da5g,848
191
191
  chellow/templates/e/dc_contract_hh_imports.html,sha256=eXFDGyzSgag4JRism81_p5yTzQOjCIXaVkQ8tl3dDcM,8172
192
192
  chellow/templates/e/dc_contracts.html,sha256=v8czpEcMzndngfWNXIKXib6Xrz9OwJjQAmNQNrQ6Y08,1705
@@ -363,6 +363,6 @@ chellow/templates/g/supply_note_edit.html,sha256=6UQf_qbhFDys3cVsTp-c7ABWZpggW9R
363
363
  chellow/templates/g/supply_notes.html,sha256=WR3YwGh_qqTklSJ7JqWX6BKBc9rk_jMff4RiWZiF2CM,936
364
364
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
365
365
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
366
- chellow-1707396281.0.0.dist-info/METADATA,sha256=znQdcRupraUVzaIpiElWdAt0Zm8UtIuzJ1Vo7Ne4Mwk,12203
367
- chellow-1707396281.0.0.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
368
- chellow-1707396281.0.0.dist-info/RECORD,,
366
+ chellow-1707995667.0.0.dist-info/METADATA,sha256=qAtfNaDLJjw2jkahNM2b5loL8f-MkeEf2NXOo2tun_E,12203
367
+ chellow-1707995667.0.0.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
368
+ chellow-1707995667.0.0.dist-info/RECORD,,