[file_handler] use NodeType throughout
This commit is contained in:
		
							parent
							
								
									be0f5a0de4
								
							
						
					
					
						commit
						47e0d5c589
					
				| @ -14,7 +14,6 @@ class ItemDescriptor(): | |||||||
|         self.value = value |         self.value = value | ||||||
|         self.entity_type = entity_type |         self.entity_type = entity_type | ||||||
|          |          | ||||||
|      |  | ||||||
| class NodeType(Enum): | class NodeType(Enum): | ||||||
|      Root = "root" |      Root = "root" | ||||||
|      Section = "section" |      Section = "section" | ||||||
| @ -92,14 +91,14 @@ class FileHandler(metaclass=Singleton): | |||||||
|         def get_subsections(section): |         def get_subsections(section): | ||||||
|             sub_sections = [] |             sub_sections = [] | ||||||
|             for s in section.sections: |             for s in section.sections: | ||||||
|                 sub_sections.append(ItemDescriptor(s.name, s.id, s.type, definition=s.definition, entity_type="Section")) |                 sub_sections.append(ItemDescriptor(s.name, s.id, s.type, definition=s.definition, entity_type=NodeType.Section)) | ||||||
|             return sub_sections |             return sub_sections | ||||||
|          |          | ||||||
|         def get_properties(section): |         def get_properties(section): | ||||||
|             props = [] |             props = [] | ||||||
|             for p in section.props: |             for p in section.props: | ||||||
|                 value = "unset" |                 value = "unset" | ||||||
|                 props.append(ItemDescriptor(p.name, p.id, value=value, entity_type="Property")) |                 props.append(ItemDescriptor(p.name, p.id, value=value, entity_type=NodeType.Property)) | ||||||
|             return props |             return props | ||||||
| 
 | 
 | ||||||
|         sections = [] |         sections = [] | ||||||
| @ -121,14 +120,14 @@ class FileHandler(metaclass=Singleton): | |||||||
|         return infos |         return infos | ||||||
|          |          | ||||||
|     def request_blocks(self): |     def request_blocks(self): | ||||||
|         return self._entity_info(self._nix_file.blocks, "Block") |         return self._entity_info(self._nix_file.blocks, NodeType.Block) | ||||||
|          |          | ||||||
|     def request_data_arrays(self, block_id): |     def request_data_arrays(self, block_id): | ||||||
|         return self._entity_info(self._nix_file.blocks[block_id].data_arrays, "DataArray") |         return self._entity_info(self._nix_file.blocks[block_id].data_arrays,NodeType.DataArray) | ||||||
| 
 | 
 | ||||||
|     def request_tags(self, block_id): |     def request_tags(self, block_id): | ||||||
|         tags = self._entity_info(self._nix_file.blocks[block_id].tags, "Tag") |         tags = self._entity_info(self._nix_file.blocks[block_id].tags, NodeType.Tag) | ||||||
|         tags.extend(self._entity_info(self._nix_file.blocks[block_id].multi_tags), "MultiTag") |         tags.extend(self._entity_info(self._nix_file.blocks[block_id].multi_tags, NodeType.MultiTag)) | ||||||
|         return tags |         return tags | ||||||
|      |      | ||||||
|     def request_references(self, block_id, tag_id, is_mtag): |     def request_references(self, block_id, tag_id, is_mtag): | ||||||
| @ -138,7 +137,7 @@ class FileHandler(metaclass=Singleton): | |||||||
|             t = b.multi_tags[tag_id] |             t = b.multi_tags[tag_id] | ||||||
|         else: |         else: | ||||||
|             t = b.tags[tag_id] |             t = b.tags[tag_id] | ||||||
|         return self._entity_info(t.references, "DataArray") |         return self._entity_info(t.references, NodeType.DataArray) | ||||||
| 
 | 
 | ||||||
|     def request_features(self, block_id, tag_id, is_mtag): |     def request_features(self, block_id, tag_id, is_mtag): | ||||||
|         b = self._nix_file.blocks[block_id] |         b = self._nix_file.blocks[block_id] | ||||||
| @ -149,7 +148,7 @@ class FileHandler(metaclass=Singleton): | |||||||
|             t = b.tags[tag_id] |             t = b.tags[tag_id] | ||||||
|         feats = [] |         feats = [] | ||||||
|         for f in t.features: |         for f in t.features: | ||||||
|             itd = ItemDescriptor(f.data.name, f.id, f.type, definition=f.data.definition, entity_type="Feature") |             itd = ItemDescriptor(f.data.name, f.id, f.type, definition=f.data.definition, entity_type=NodeType.Feature) | ||||||
|             feats.append(itd) |             feats.append(itd) | ||||||
|         return feats |         return feats | ||||||
|      |      | ||||||
| @ -158,5 +157,5 @@ class FileHandler(metaclass=Singleton): | |||||||
|         for i, d in enumerate(self._nix_file.blocks[block_id].data_arrays[array_id].dimensions): |         for i, d in enumerate(self._nix_file.blocks[block_id].data_arrays[array_id].dimensions): | ||||||
|             dim_name = "%i. dim: %s" % (i+1, d.label if hasattr(d, "label") else "") |             dim_name = "%i. dim: %s" % (i+1, d.label if hasattr(d, "label") else "") | ||||||
|             dim_type= "%s %s" % (d.dimension_type, "dimension") |             dim_type= "%s %s" % (d.dimension_type, "dimension") | ||||||
|             dimensions.append(ItemDescriptor(dim_name, type=dim_type, entity_type="Dimension")) |             dimensions.append(ItemDescriptor(dim_name, type=dim_type, entity_type=NodeType.Dimension)) | ||||||
|         return dimensions |         return dimensions | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user