[file handler] add method get an ItemDescriptor for a single section
This commit is contained in:
parent
fcbd0091ad
commit
7a1cc02d99
@ -179,6 +179,17 @@ class FileHandler(metaclass=Singleton):
|
|||||||
def filename(self):
|
def filename(self):
|
||||||
return self._filename
|
return self._filename
|
||||||
|
|
||||||
|
def request_section_descriptor(self, id):
|
||||||
|
fs = self._entity_buffer.get(id)
|
||||||
|
if fs is None:
|
||||||
|
found_section = self._nix_file.find_sections(lambda s: s.id == id)
|
||||||
|
fs = found_section[0] if len(found_section) > 0 else None
|
||||||
|
if fs is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
item = ItemDescriptor(fs.name, fs.id, fs.type, definition=fs.definition, entity_type=NodeType.Section)
|
||||||
|
return item
|
||||||
|
|
||||||
def request_metadata(self, root_id=None, depth=1):
|
def request_metadata(self, root_id=None, depth=1):
|
||||||
"""[summary]
|
"""[summary]
|
||||||
|
|
||||||
@ -196,7 +207,22 @@ class FileHandler(metaclass=Singleton):
|
|||||||
def get_properties(section):
|
def get_properties(section):
|
||||||
props = []
|
props = []
|
||||||
for p in section.props:
|
for p in section.props:
|
||||||
value = "unset"
|
value = ""
|
||||||
|
if self._file_version < (1,1,1):
|
||||||
|
vals = p.values
|
||||||
|
if len(vals) > 1:
|
||||||
|
value += "["
|
||||||
|
value += ",".join(map(str, [v.value for v in vals]))
|
||||||
|
value += "]"
|
||||||
|
else:
|
||||||
|
value = str(vals[0].value)
|
||||||
|
else:
|
||||||
|
vals = p.values
|
||||||
|
value += "["
|
||||||
|
value += ",".join(map(str, [v.value for v in vals]))
|
||||||
|
value += "]"
|
||||||
|
if p.unit is not None:
|
||||||
|
value += " " + p.unit
|
||||||
props.append(ItemDescriptor(p.name, p.id, value=value, entity_type=NodeType.Property))
|
props.append(ItemDescriptor(p.name, p.id, value=value, entity_type=NodeType.Property))
|
||||||
return props
|
return props
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user