chellow 1739889885.0.0__py3-none-any.whl → 1740066311.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/computer.py CHANGED
@@ -119,11 +119,15 @@ def contract_func(caches, contract, func_name):
119
119
  return ns.get(func_name, None)
120
120
 
121
121
 
122
- def non_core_rate(sess, caches, contract_id_or_name, date):
123
- return hh_rate(sess, caches, contract_id_or_name, date, market_role_code="Z")
122
+ def non_core_rate(sess, caches, contract_id_or_name, date, exact=False):
123
+ return hh_rate(
124
+ sess, caches, contract_id_or_name, date, market_role_code="Z", exact=exact
125
+ )
124
126
 
125
127
 
126
- def hh_rate(sess, caches, contract_id_or_name, date, market_role_code=None):
128
+ def hh_rate(
129
+ sess, caches, contract_id_or_name, date, market_role_code=None, exact=False
130
+ ):
127
131
  try:
128
132
  ccache = caches["computer"]
129
133
  except KeyError:
@@ -181,18 +185,20 @@ def hh_rate(sess, caches, contract_id_or_name, date, market_role_code=None):
181
185
  )
182
186
 
183
187
  if rs is None:
184
- rs = (
188
+ last_rs = (
185
189
  sess.query(RateScript)
186
190
  .filter(RateScript.contract == contract)
187
191
  .order_by(RateScript.start_date.desc())
188
192
  .first()
189
193
  )
190
- if date < rs.start_date:
194
+ if date < last_rs.start_date:
191
195
  cstart = year_before
192
- cfinish = min(year_after, rs.start_date - HH)
196
+ cfinish = min(year_after, last_rs.start_date - HH)
193
197
  else:
194
- cstart = max(rs.finish_date + HH, year_before)
198
+ cstart = max(last_rs.finish_date + HH, year_before)
195
199
  cfinish = year_after
200
+ if not exact:
201
+ rs = last_rs
196
202
  else:
197
203
  cstart = max(rs.start_date, year_before)
198
204
  if rs.finish_date is None:
@@ -200,23 +206,26 @@ def hh_rate(sess, caches, contract_id_or_name, date, market_role_code=None):
200
206
  else:
201
207
  cfinish = min(rs.finish_date, year_after)
202
208
 
203
- market_role_code = rs.contract.market_role.code
204
- if market_role_code == "M":
205
- seg = "/e/mop_rate_scripts/"
206
- elif market_role_code == "C":
207
- seg = "/e/dc_rate_scripts/"
208
- elif market_role_code == "X":
209
- seg = "/e/supplier_rate_scripts/"
210
- elif market_role_code == "Z":
211
- seg = "/non_core_rate_scripts/"
212
- elif market_role_code == "R":
213
- seg = "/e/dno_rate_scripts/"
209
+ if rs is None:
210
+ vals = None
214
211
  else:
215
- raise Exception(
216
- f"The market role code {market_role_code} isn't recognized."
217
- )
212
+ market_role_code = rs.contract.market_role.code
213
+ if market_role_code == "M":
214
+ seg = "/e/mop_rate_scripts/"
215
+ elif market_role_code == "C":
216
+ seg = "/e/dc_rate_scripts/"
217
+ elif market_role_code == "X":
218
+ seg = "/e/supplier_rate_scripts/"
219
+ elif market_role_code == "Z":
220
+ seg = "/non_core_rate_scripts/"
221
+ elif market_role_code == "R":
222
+ seg = "/e/dno_rate_scripts/"
223
+ else:
224
+ raise Exception(
225
+ f"The market role code {market_role_code} isn't recognized."
226
+ )
218
227
 
219
- vals = PropDict(f"the rate script {seg}{rs.id} ", loads(rs.script), [])
228
+ vals = PropDict(f"the rate script {seg}{rs.id} ", loads(rs.script), [])
220
229
  for dt in hh_range(caches, cstart, cfinish):
221
230
  if dt not in cont_cache:
222
231
  cont_cache[dt] = vals
@@ -572,8 +581,10 @@ class DataSource:
572
581
  self.rate_cache = self.caches["computer"]["rates"]
573
582
  return val
574
583
 
575
- def non_core_rate(self, contract_name_or_id, date):
576
- return non_core_rate(self.sess, self.caches, contract_name_or_id, date)
584
+ def non_core_rate(self, contract_name_or_id, date, exact=False):
585
+ return non_core_rate(
586
+ self.sess, self.caches, contract_name_or_id, date, exact=exact
587
+ )
577
588
 
578
589
  def _add_problem(self, problem):
579
590
  self.supplier_bill["problem"] += problem
chellow/e/tlms.py CHANGED
@@ -36,7 +36,11 @@ def hh(data_source, run="DF"):
36
36
  h["tlm"] = tlm = cache[h["start-date"]][gsp_group_code][run]
37
37
  except KeyError:
38
38
  h_start = h["start-date"]
39
- rates = data_source.non_core_rate("tlms", h_start)["tlms"]
39
+ vals = data_source.non_core_rate("tlms", h_start, exact=True)
40
+ if vals is None:
41
+ vals = data_source.non_core_rate("tlms", h["hist-start"])
42
+
43
+ rates = vals["tlms"]
40
44
 
41
45
  key = key_format(h_start)
42
46
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chellow
3
- Version: 1739889885.0.0
3
+ Version: 1740066311.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,7 +20,7 @@ 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=Fq4SpEvCLArZHOGgSGqvm7mdAVLiswnNWspuuft4h70,67460
23
+ chellow/e/computer.py,sha256=KkYNaD4W13s_BvtyPrYbfZ9MU73hKi-IIL-g4OOQxBA,67787
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
@@ -40,7 +40,7 @@ chellow/e/rcrc.py,sha256=92CA1uIotIHd1epQ_jEPdJKzXqDFV-AoJOJeRO6MEyA,4274
40
40
  chellow/e/ro.py,sha256=dZKZv_9wXSWuwcb3jiKavoD_9ot-PZseNVeEEe0siLo,596
41
41
  chellow/e/scenario.py,sha256=FLgh03r_SgXx0hMWFbAvwsz2ScDL8LUwYWSWVv2rQlg,24973
42
42
  chellow/e/system_price.py,sha256=6w5J7bzwFAZubE2zdOFRiS8IIrVP8hkoIOaG2yCt-Ic,6232
43
- chellow/e/tlms.py,sha256=M33D6YpMixu2KkwSCzDRM3kThLgShg8exp63Obo75l8,8905
43
+ chellow/e/tlms.py,sha256=Wb9ZuxscMzxXs0FT06Iu5YXeccmO6ai_mUjnJGJwTM4,9045
44
44
  chellow/e/tnuos.py,sha256=NBmc-f3oezrl4gviAKobljHfICTpBKxxxEGBGJi_lRk,4927
45
45
  chellow/e/triad.py,sha256=lIQj7EdUrcFwEqleuHZXYU_bfzIwNOqUVVxB3NPQt4A,13710
46
46
  chellow/e/views.py,sha256=ZDVUirf0fMLO8aS5gF3xpPnRDmNqYxxGHkGjxm0_AY4,220901
@@ -378,6 +378,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
378
378
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
379
379
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
380
380
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
381
- chellow-1739889885.0.0.dist-info/METADATA,sha256=iQJxsDUYm0NRHUc8O70ShLjSedd-0j5cjZh_5ojdJuw,12204
382
- chellow-1739889885.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
383
- chellow-1739889885.0.0.dist-info/RECORD,,
381
+ chellow-1740066311.0.0.dist-info/METADATA,sha256=Ptkn8LQ0lzGXaW-pi11oteZKiDLxBJuK0WvC7HpscYY,12204
382
+ chellow-1740066311.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
383
+ chellow-1740066311.0.0.dist-info/RECORD,,