[cleanup]
This commit is contained in:
parent
ddb39146cd
commit
fc65542aee
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@
|
||||
target
|
||||
env/
|
||||
__pycache__
|
||||
main.spec
|
||||
main.spec
|
||||
*.afdesign
|
@ -14,7 +14,8 @@ class ItemDescriptor():
|
||||
self.definition = definition
|
||||
self.value = value
|
||||
self.entity_type = entity_type
|
||||
|
||||
|
||||
|
||||
class NodeType(Enum):
|
||||
Root = "root"
|
||||
Section = "section"
|
||||
@ -28,7 +29,7 @@ class NodeType(Enum):
|
||||
MultiTag = "multi_tag"
|
||||
Group = "group"
|
||||
Feature="feature"
|
||||
|
||||
|
||||
|
||||
class Singleton(type):
|
||||
_instances = {}
|
||||
@ -37,6 +38,7 @@ class Singleton(type):
|
||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
|
||||
|
||||
class FileHandler(metaclass=Singleton):
|
||||
|
||||
def __init__(self) -> None:
|
||||
@ -70,12 +72,11 @@ class FileHandler(metaclass=Singleton):
|
||||
self._nix_file.close()
|
||||
self._nix_file = None
|
||||
self._file_requests = []
|
||||
|
||||
|
||||
def file_descriptor(self):
|
||||
|
||||
return ItemDescriptor()
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def is_valid(self):
|
||||
return self._nix_file is not None and self._nix_file.is_open()
|
||||
@ -83,7 +84,7 @@ class FileHandler(metaclass=Singleton):
|
||||
@property
|
||||
def filename(self):
|
||||
return self._filename
|
||||
|
||||
|
||||
def request_metadata(self, root_id=None, depth=1):
|
||||
"""[summary]
|
||||
|
||||
@ -122,10 +123,10 @@ class FileHandler(metaclass=Singleton):
|
||||
infos.append(itd)
|
||||
# TODO set the value to something meaningful for the various entity types
|
||||
return infos
|
||||
|
||||
|
||||
def request_blocks(self):
|
||||
return self._entity_info(self._nix_file.blocks, None, NodeType.Block)
|
||||
|
||||
|
||||
def request_data_arrays(self, block_id):
|
||||
return self._entity_info(self._nix_file.blocks[block_id].data_arrays, block_id, NodeType.DataArray)
|
||||
|
||||
@ -133,7 +134,7 @@ class FileHandler(metaclass=Singleton):
|
||||
tags = self._entity_info(self._nix_file.blocks[block_id].tags, block_id, NodeType.Tag)
|
||||
tags.extend(self._entity_info(self._nix_file.blocks[block_id].multi_tags, block_id, NodeType.MultiTag))
|
||||
return tags
|
||||
|
||||
|
||||
def request_references(self, block_id, tag_id, is_mtag):
|
||||
b = self._nix_file.blocks[block_id]
|
||||
t = None
|
||||
@ -155,7 +156,7 @@ class FileHandler(metaclass=Singleton):
|
||||
itd = ItemDescriptor(f.data.name, f.id, f.link_type, definition=f.data.definition, block_id=block_id, entity_type=NodeType.Feature)
|
||||
feats.append(itd)
|
||||
return feats
|
||||
|
||||
|
||||
def request_dimensions(self, block_id, array_id):
|
||||
dimensions = []
|
||||
for i, d in enumerate(self._nix_file.blocks[block_id].data_arrays[array_id].dimensions):
|
||||
@ -163,12 +164,12 @@ class FileHandler(metaclass=Singleton):
|
||||
dim_type= "%s %s" % (d.dimension_type, "dimension")
|
||||
dimensions.append(ItemDescriptor(dim_name, type=dim_type, entity_type=NodeType.Dimension, block_id=block_id))
|
||||
return dimensions
|
||||
|
||||
|
||||
def request_data_frames(self, block_id):
|
||||
if self._nix_file.version[1] >= 2:
|
||||
return self._entity_info(self._nix_file.blocks[block_id].data_frames, block_id, NodeType.DataFrame)
|
||||
return []
|
||||
|
||||
|
||||
def request_groups(self, block_id):
|
||||
return self._entity_info(self._nix_file.blocks[block_id].groups, block_id, NodeType.Group)
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
from PyQt5.QtCore import QAbstractItemModel, QFile, QModelIndex, QSize, Qt
|
||||
from PyQt5.QtCore import QAbstractItemModel, QModelIndex, Qt
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QHeaderView, QTreeWidgetItem
|
||||
from PyQt5.QtWidgets import QTreeWidgetItem
|
||||
|
||||
from file_handler import ItemDescriptor, NodeType
|
||||
from IPython import embed
|
||||
|
||||
column_names = ['Name', 'Type', 'ID', 'Value', 'Description']
|
||||
|
||||
@ -56,7 +55,7 @@ class NixTreeItem(QTreeWidgetItem):
|
||||
return self._parent_item._child_items.index(self)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
class FileTreeItem(NixTreeItem):
|
||||
def __init__(self, node_descriptor, file_handler, parent=None):
|
||||
super().__init__(node_descriptor, file_handler=file_handler, parent=parent)
|
||||
|
Loading…
Reference in New Issue
Block a user