Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit fa40b04

Browse files
committed
accumulations
1 parent 7fecf48 commit fa40b04

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

β€Žecml_tools/create/functions/steps/rename.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# nor does it submit to any jurisdiction.
88
#
99

10+
import re
11+
1012
from climetlab.indexing.fieldset import FieldArray
1113

1214

@@ -30,20 +32,22 @@ class RenamedFieldFormat:
3032
def __init__(self, field, format):
3133
self.field = field
3234
self.format = format
35+
self.bits = re.findall(r"{(\w+)}", format)
3336

3437
def metadata(self, key):
3538
value = self.field.metadata(key)
36-
# print('βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ…βœ… ====> ', key, value, self.format)
3739
if "{" + key + "}" in self.format:
38-
return self.format.format(**{key: value})
40+
bits = {b: self.field.metadata(b) for b in self.bits}
41+
return self.format.format(**bits)
3942
return value
4043

4144
def __getattr__(self, name):
4245
return getattr(self.field, name)
4346

4447

4548
def execute(context, input, what="param", **kwargs):
46-
if "{" in what:
47-
return FieldArray([RenamedFieldFormat(fs, what) for fs in input])
49+
# print('🍍🍍🍍🍍🍍🍍🍍🍍🍍🍍🍍🍍🍍 ==========', kwargs)
50+
if what in kwargs:
51+
return FieldArray([RenamedFieldFormat(fs, kwargs[what]) for fs in input])
4852

4953
return FieldArray([RenamedFieldMapping(fs, what, kwargs) for fs in input])

β€Žecml_tools/create/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ def step_factory(config, context, action_path, previous_step):
852852
raise ValueError(f"Unknown step {key}")
853853
cls = FunctionStepAction
854854
args = [key] + args
855-
print("========", args)
855+
# print("========", args)
856856

857857
return cls(context, action_path, previous_step, *args, **kwargs)
858858

β€Žecml_tools/create/loaders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def load(self):
366366
LOG.info(f" -> Skipping {igroup} total={len(self.groups)} (already done)")
367367
continue
368368
self.print(f" -> Processing {igroup} total={len(self.groups)}")
369-
print("========", group)
369+
# print("========", group)
370370
assert isinstance(group[0], datetime.datetime), group
371371

372372
result = self.input.select(dates=group)

0 commit comments

Comments
Β (0)