chellow 1728924490.0.0__py3-none-any.whl → 1729012049.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/bill_parsers/mm.py +2 -1
- chellow/e/computer.py +8 -2
- chellow/e/hh_importer.py +1 -1
- chellow/e/hh_parser_edf_csv.py +102 -0
- chellow/templates/e/scenario_docs.html +2 -1
- {chellow-1728924490.0.0.dist-info → chellow-1729012049.0.0.dist-info}/METADATA +1 -1
- {chellow-1728924490.0.0.dist-info → chellow-1729012049.0.0.dist-info}/RECORD +8 -7
- {chellow-1728924490.0.0.dist-info → chellow-1729012049.0.0.dist-info}/WHEEL +0 -0
chellow/e/bill_parsers/mm.py
CHANGED
|
@@ -172,7 +172,8 @@ def _handle_0461(headers, pre_record, record):
|
|
|
172
172
|
mpan_core = parse_mpan_core(parts["mpan_core"])
|
|
173
173
|
headers["mpan_core"] = mpan_core
|
|
174
174
|
units = CONSUMPTION_UNITS_LOOKUP[parts["units"].strip()]
|
|
175
|
-
|
|
175
|
+
register_code = parts["register_code"].strip()
|
|
176
|
+
if units == "kWh" and not register_code.startswith("NOCHARGE"):
|
|
176
177
|
headers["kwh"] += Decimal(parts["quantity"])
|
|
177
178
|
|
|
178
179
|
prev_read_date_str = parts["prev_read_date"].strip()
|
chellow/e/computer.py
CHANGED
|
@@ -993,7 +993,10 @@ class SupplySource(DataSource):
|
|
|
993
993
|
else:
|
|
994
994
|
self.llfc = era.imp_llfc
|
|
995
995
|
|
|
996
|
-
|
|
996
|
+
if "imp_sc" in self.era_map:
|
|
997
|
+
self.sc = self.era_map["imp_sc"]
|
|
998
|
+
else:
|
|
999
|
+
self.sc = era.imp_sc
|
|
997
1000
|
self.supplier_account = era.imp_supplier_account
|
|
998
1001
|
|
|
999
1002
|
if era.imp_supplier_contract.id in self.era_map_supplier_contracts:
|
|
@@ -1020,7 +1023,10 @@ class SupplySource(DataSource):
|
|
|
1020
1023
|
else:
|
|
1021
1024
|
self.llfc = era.exp_llfc
|
|
1022
1025
|
|
|
1023
|
-
|
|
1026
|
+
if "exp_sc" in self.era_map:
|
|
1027
|
+
self.sc = self.era_map["exp_sc"]
|
|
1028
|
+
else:
|
|
1029
|
+
self.sc = era.exp_sc
|
|
1024
1030
|
self.supplier_account = era.exp_supplier_account
|
|
1025
1031
|
|
|
1026
1032
|
if era.exp_supplier_contract is None:
|
chellow/e/hh_importer.py
CHANGED
|
@@ -40,7 +40,7 @@ from chellow.utils import (
|
|
|
40
40
|
processes = defaultdict(list)
|
|
41
41
|
tasks = {}
|
|
42
42
|
|
|
43
|
-
extensions = [".df2", ".simple.csv", ".bg.csv", ".vital.xlsx"]
|
|
43
|
+
extensions = [".df2", ".simple.csv", ".bg.csv", ".vital.xlsx", ".edf.csv"]
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
class HhDataImportProcess(threading.Thread):
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
from codecs import iterdecode
|
|
3
|
+
from datetime import datetime as Datetime
|
|
4
|
+
from decimal import Decimal
|
|
5
|
+
|
|
6
|
+
from werkzeug.exceptions import BadRequest
|
|
7
|
+
|
|
8
|
+
from chellow.utils import (
|
|
9
|
+
HH,
|
|
10
|
+
parse_mpan_core,
|
|
11
|
+
to_ct,
|
|
12
|
+
to_utc,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# From the EDF Portal select:
|
|
16
|
+
# - Electricity
|
|
17
|
+
# - Half-hourly
|
|
18
|
+
# - Reactive Power and kWh combined
|
|
19
|
+
# export data as CSV
|
|
20
|
+
#
|
|
21
|
+
#
|
|
22
|
+
# "Month","MPAN","Measurement Type","Settlement Date","00:00",..,"00:00_Act_Est",
|
|
23
|
+
# "Apr-24", "2200000000000", "AI", "01-04-2024", "0.0000", ..., "Actual", "Actual",
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def create_parser(reader, mpan_map, messages):
|
|
27
|
+
return HhParserEdfCsv(reader, mpan_map, messages)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
CHANNEL_LOOKUP = {
|
|
31
|
+
"AI": "ACTIVE",
|
|
32
|
+
"RI": "REACTIVE_IMP",
|
|
33
|
+
"RE": "REACTIVE_EXP",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
STATUS_LOOKUP = {
|
|
37
|
+
"Actual": "A",
|
|
38
|
+
"Estimated": "E",
|
|
39
|
+
"-": "E",
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _get_field(values, index, name):
|
|
44
|
+
if len(values) > index:
|
|
45
|
+
return values[index].strip()
|
|
46
|
+
else:
|
|
47
|
+
raise BadRequest(f"Can't find field {index}, {name}.")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _find_data(shredder):
|
|
51
|
+
try:
|
|
52
|
+
for line_number, values in enumerate(shredder, start=2):
|
|
53
|
+
mpan_core_str = _get_field(values, 1, "MPAN Core")
|
|
54
|
+
mpan_core = parse_mpan_core(mpan_core_str)
|
|
55
|
+
channel_type_str = _get_field(values, 2, "Channel Type")
|
|
56
|
+
channel_type = CHANNEL_LOOKUP[channel_type_str]
|
|
57
|
+
start_day_ct_str = _get_field(values, 3, "Day")
|
|
58
|
+
start_day_ct = to_ct(Datetime.strptime(start_day_ct_str, "%d-%m-%Y"))
|
|
59
|
+
|
|
60
|
+
for i in range(50):
|
|
61
|
+
val_idx = i + 4
|
|
62
|
+
value_str = values[val_idx]
|
|
63
|
+
if value_str == "-":
|
|
64
|
+
break
|
|
65
|
+
|
|
66
|
+
status_idx = val_idx + 50
|
|
67
|
+
status_str = values[status_idx]
|
|
68
|
+
try:
|
|
69
|
+
status = STATUS_LOOKUP[status_str]
|
|
70
|
+
except KeyError:
|
|
71
|
+
raise BadRequest(
|
|
72
|
+
f"Unrecognized status {status_str} at index {status_idx}."
|
|
73
|
+
)
|
|
74
|
+
yield {
|
|
75
|
+
"mpan_core": mpan_core,
|
|
76
|
+
"channel_type": channel_type,
|
|
77
|
+
"start_date": to_utc(start_day_ct + HH * i),
|
|
78
|
+
"value": Decimal(value_str),
|
|
79
|
+
"status": status,
|
|
80
|
+
}
|
|
81
|
+
except BadRequest as e:
|
|
82
|
+
e.description = (
|
|
83
|
+
f"Problem at line number: {line_number} : {values} : {e.description}"
|
|
84
|
+
)
|
|
85
|
+
raise e
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class HhParserEdfCsv:
|
|
89
|
+
def __init__(self, reader, mpan_map, messages):
|
|
90
|
+
s = iterdecode(reader, "utf-8")
|
|
91
|
+
self.reader = csv.reader(s)
|
|
92
|
+
next(self.reader) # skip the title line
|
|
93
|
+
self.data = iter(_find_data(self.reader))
|
|
94
|
+
|
|
95
|
+
def __iter__(self):
|
|
96
|
+
return self
|
|
97
|
+
|
|
98
|
+
def __next__(self):
|
|
99
|
+
return next(self.data)
|
|
100
|
+
|
|
101
|
+
def close(self):
|
|
102
|
+
self.shredder.close()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: chellow
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1729012049.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)
|
|
@@ -20,14 +20,15 @@ chellow/e/bmarketidx.py,sha256=C0BaHn2RxIuWH2QzA-OmSP0fbUGvW9tqEUhLnzOEdmA,7968
|
|
|
20
20
|
chellow/e/bsuos.py,sha256=hdP9vnOJSuZl46OAkJeUg1XJYvYIBj4J6Sqce1Hy9Vs,15542
|
|
21
21
|
chellow/e/ccl.py,sha256=30dh_SvlgzsTQPPAJNZWILaMvbeDsv9-P-S1JxS5_SQ,3184
|
|
22
22
|
chellow/e/cfd.py,sha256=Gm435c42LFwZx1n-1UY1Tdx6mL1is7E0vRLWQe8RPOo,14184
|
|
23
|
-
chellow/e/computer.py,sha256=
|
|
23
|
+
chellow/e/computer.py,sha256=24aBfC-aYoTseRwQSNRAb1PwTKp0zL9aispceL8drcU,67469
|
|
24
24
|
chellow/e/dno_rate_parser.py,sha256=A5TP6KjyfT5lVWh7dX4SiXRi6wnf2lGv-H_T4Sod8CI,21731
|
|
25
25
|
chellow/e/duos.py,sha256=nwviRjz-qIt3GxIMHk0hItIT4dtKsxOWq9TUC1z-hO8,30864
|
|
26
26
|
chellow/e/elexon.py,sha256=ALhXS9Es7PV0z9ukPbIramn3cf3iLyFi-PMWPSm5iOs,5487
|
|
27
27
|
chellow/e/energy_management.py,sha256=aXC2qlGt3FAODlNl_frWzVYAQrJLP8FFOiNX3m-QE_Y,12388
|
|
28
|
-
chellow/e/hh_importer.py,sha256=
|
|
28
|
+
chellow/e/hh_importer.py,sha256=Bo1kWV2po3VY5DJPlNqgWtz4xaU3h1-R2JtFmCEX37g,21442
|
|
29
29
|
chellow/e/hh_parser_bg_csv.py,sha256=W5SU2MSpa8BGA0VJw1JXF-IwbCNLFy8fe35yxLZ7gEw,2453
|
|
30
30
|
chellow/e/hh_parser_df2.py,sha256=tRAoVUUoJDlfPopm6usEBnhJz7dXMc2_KEWbkW9Gyq4,4330
|
|
31
|
+
chellow/e/hh_parser_edf_csv.py,sha256=CLkkL1Z6BPgVV_3uwS6McmtMzgXkoEIoJnH8FsQk1C8,2839
|
|
31
32
|
chellow/e/hh_parser_simple_csv.py,sha256=lJx9tw9BWFSoBmns1Cws_vY-OIn90LPt2yvIN_CFcTE,2177
|
|
32
33
|
chellow/e/hh_parser_vital_xlsx.py,sha256=g9-CElfH1PPfwpuUcVvD6WQpBlNxCo8j9pq_0Yza0ZM,4125
|
|
33
34
|
chellow/e/laf_import.py,sha256=aqkcbjnvfBPszBLSNg6getP7iW1uWiTVHy6N5Z5x39U,5514
|
|
@@ -54,7 +55,7 @@ chellow/e/bill_parsers/gdf_csv.py,sha256=ZfK3Oc6oP28p_P9DIevLNB_zW2WLcEJ3Lvb1gL3
|
|
|
54
55
|
chellow/e/bill_parsers/haven_csv.py,sha256=0uENq8IgVNqdxfBQMBxLTSZWCOuDHXZC0xzk52SbfyE,13652
|
|
55
56
|
chellow/e/bill_parsers/haven_edi.py,sha256=YGPHRxPOhje9s32jqPHHELni2tooOYj3cMC_qaZVPq4,16107
|
|
56
57
|
chellow/e/bill_parsers/haven_edi_tprs.py,sha256=ZVX9CCqUybsot_Z0BEOJPvl9x5kSr7fEWyuJXvZDcz4,11841
|
|
57
|
-
chellow/e/bill_parsers/mm.py,sha256=
|
|
58
|
+
chellow/e/bill_parsers/mm.py,sha256=56_nfXNrt_ZZRwoHnj5xTi6Emh9I2wY4JJSaNxmwcCc,10038
|
|
58
59
|
chellow/e/bill_parsers/nonsettlement_dc_stark_xlsx.py,sha256=yogXTuQHGRL7IiqvRWr2C9V24ez1j9Yx0128UygPE_k,4723
|
|
59
60
|
chellow/e/bill_parsers/settlement_dc_stark_xlsx.py,sha256=PlEqCZuJ9DfQXeeYQ64jtf3ML7sUt_tt61QOOTnkE5c,6380
|
|
60
61
|
chellow/e/bill_parsers/sse_edi.py,sha256=L85DOfNkqexeEIEr8pCBn_2sHJI-zEaw6cogpE3YyYM,15204
|
|
@@ -277,7 +278,7 @@ chellow/templates/e/read_type.html,sha256=volKteZB79famXrzN_Bgqy9JT9C4a50vXLkuZ0
|
|
|
277
278
|
chellow/templates/e/read_types.html,sha256=CknHXNEkBnsAprqI66ftvnnMFBdR_kqI7o26rxjlrJA,473
|
|
278
279
|
chellow/templates/e/scenario.html,sha256=E8o3WQwAEejzaMPzeuUqyt9fWWNSDtN96qkJz0slDEo,1522
|
|
279
280
|
chellow/templates/e/scenario_add.html,sha256=qQpxvhlrQqrNYiIQTHu_NvSoeSKuRNEJQYwLqRlQ8_U,516
|
|
280
|
-
chellow/templates/e/scenario_docs.html,sha256
|
|
281
|
+
chellow/templates/e/scenario_docs.html,sha256=QxcX30Y0EJ0KDH0OBZs91a48FSehUEpT8qT1QhuXnRk,4971
|
|
281
282
|
chellow/templates/e/scenario_edit.html,sha256=Uf64v_qsBP0BxaFEIz214CC_dZXlvro4zvQXH_towhA,1070
|
|
282
283
|
chellow/templates/e/scenarios.html,sha256=zlNhZvQEcuwLgHObVHS-4THur5Lz9Jf1G6xD98-jamI,847
|
|
283
284
|
chellow/templates/e/site_add_e_supply.html,sha256=_gi1ejI4TMTMX9vCW7z2kToR2XKR6qoVh67qp_VrDsM,2731
|
|
@@ -368,6 +369,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
|
|
|
368
369
|
chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
|
|
369
370
|
chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
|
|
370
371
|
chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
|
|
371
|
-
chellow-
|
|
372
|
-
chellow-
|
|
373
|
-
chellow-
|
|
372
|
+
chellow-1729012049.0.0.dist-info/METADATA,sha256=KGncQBfTFXII_d4142UqVWnPjzQDIkmVbxHvd9Bj9-Y,12204
|
|
373
|
+
chellow-1729012049.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
374
|
+
chellow-1729012049.0.0.dist-info/RECORD,,
|
|
File without changes
|