RootSystemTracker support and fix loader/writer round-trip PR#34
Merged
pradal merged 4 commits intoopenalea:hirrosfrom Dec 10, 2025
Merged
RootSystemTracker support and fix loader/writer round-trip PR#34pradal merged 4 commits intoopenalea:hirrosfrom
pradal merged 4 commits intoopenalea:hirrosfrom
Conversation
pradal
requested changes
Nov 13, 2025
|
|
||
| # 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: |
Contributor
There was a problem hiding this comment.
Get just ones graph_properties rather than calling each time.
Code will be simpler, nicer.
props = graph.graph_properties()
Contributor
There was a problem hiding this comment.
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'): |
Contributor
There was a problem hiding this comment.
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') |
| function_elt.attrib['name'] = tag | ||
|
|
||
| for sample in attrib[tag]: | ||
| for sample in props[tag]: |
| except OSError: # no such file | ||
| pass | ||
|
|
||
|
|
Contributor
There was a problem hiding this comment.
why not...
Security flaw but ... we do not care
| # table of observation times | ||
| obs = metadata['observation-hours'] | ||
| if isinstance(obs, str): | ||
| import ast |
Contributor
There was a problem hiding this comment.
import at the begining of the file with ... imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.