-
Notifications
You must be signed in to change notification settings - Fork 3
RootSystemTracker support and fix loader/writer round-trip PR #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| # if some functions are defined in the MTG properties but not in metadata, add them | ||
| graph = self._g | ||
| if graph.graph_properties().get('metadata', {}).get('functions') is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get just ones graph_properties rather than calling each time.
Code will be simpler, nicer.
props = graph.graph_properties()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or directly for metadata
metadata = graph.graph_properties().set_default('metadata', {})| graph = self._g | ||
| if graph.graph_properties().get('metadata', {}).get('functions') is None: | ||
| graph.graph_properties()['metadata']['functions'] = [] | ||
| if graph.properties().get('time'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
props is a dict, isn't it?
Just do
if 'time' in props:| for tag in pname: | ||
| if tag in props: | ||
| if functions_elt is None: | ||
| functions_elt = self.SubElement(xml_elt, 'functions') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good.
| function_elt.attrib['name'] = tag | ||
|
|
||
| for sample in attrib[tag]: | ||
| for sample in props[tag]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep.
| except OSError: # no such file | ||
| pass | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not...
Security flaw but ... we do not care
| # table of observation times | ||
| obs = metadata['observation-hours'] | ||
| if isinstance(obs, str): | ||
| import ast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import at the begining of the file with ... imports
rootandfunctions(Dumperclass)observation_hoursproperty in metadata if accessibletime,time_hoursordiameterare loaded as graph_properties but not defined as functions in metadata, we add themThis has only been tested on RSMLs issued by RootSystemTracker.