Closed philngo closed 8 years ago
Taking a stab at this. Any thoughts?
pyyaml which we're using for parsing may have some helpful yaml writing tools, but I haven't looked closely. This may be a bit of a hairy issue for meters like the DefaultResidentialMeter (previously PRISMMeter), which use meter yaml internally, but aren't directly instantiated from YAML, but should be much more straightforward for other meters.
The meters to pay particularly close attention to are those defined in eemeter.meter.control, which provide control flow by calling other sub meters. For example, the Sequential Meter has a special attribute sequence
, which contains a list of meters which should also be serialized to YAML.
Ok. thanks
So one think to think about is that JSON and therefore __dict__
is valid yaml?
Here's a first pass at this - it doesn't take advantage of the similarity to json, but it does fit in nicely with the existing framework for loading yaml.
Haven't yet tried reading the dumped yaml back in, but that's probably the best way to test it.
We might also consider adding in a comment somewhere in the output for eemeter version compatibility.
Pretty impressive work, I wouldn't have come up with this in ages. :+1: :fireworks:
I can take a look tomorrow at the latter two issues.
This would make it a bit easier to construct modular components for subbing into other meters.