emrichen
emrichen copied to clipboard
`!Lookup` does not enrich on the fly
Template:
!Defaults
x:
y: 5
z: !Var x
---
workie: !Lookup x.y
no_workie: !Lookup z.y
Expected output:
workie: 5
no_workie: 5
Actual output:
Traceback (most recent call last):
File "/usr/local/bin/emrichen", line 11, in <module>
load_entry_point('emrichen', 'console_scripts', 'emrichen')()
File "/Users/sapaj1/Hobby/emrichen/emrichen/__main__.py", line 111, in main
output = template.render(context, format=args.output_format)
File "/Users/sapaj1/Hobby/emrichen/emrichen/template.py", line 22, in render
enriched = self.enrich(context)
File "/Users/sapaj1/Hobby/emrichen/emrichen/template.py", line 19, in enrich
return context.enrich(self.template)
File "/Users/sapaj1/Hobby/emrichen/emrichen/context.py", line 37, in enrich
item = self.enrich(item)
File "/Users/sapaj1/Hobby/emrichen/emrichen/context.py", line 30, in enrich
val = self.enrich(val)
File "/Users/sapaj1/Hobby/emrichen/emrichen/context.py", line 21, in enrich
return self.enrich(value.enrich(self))
File "/Users/sapaj1/Hobby/emrichen/emrichen/tags/lookup.py", line 19, in enrich
raise KeyError(f'{self}: no matches for {self.data}')
KeyError: "Lookup('z.y'): no matches for z.y"
I guess we'll have to augment the JSONPath resolver to maybe_enrich
when it traverses.
Yeah, the JSONPath resolver isn't that easy to hack to do this, unfortunately.
I had a similar issue when using With
, I wanted vars
to be enriched:
rows: !Loop
over: !Var subareaRows
as: row
template: !Merge
- context: !Var parentContext
color: !Lookup row.color
- !With
template:
geoid: !Var geoid
vars: !LookupGeometry
path: !Var datasetUrl
context: !Var parentContext
lookup:
subarea_name: !Lookup row.name