Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def sync_children(self, item):
if isinstance(item.node, NXgroup):
children = []
if item.hasChildren():
for row in range(item.rowCount()):
children.append(item.child(row))
names = [child.text() for child in children]
for name in item.node:
if name not in names:
item.appendRow(NXTreeItem(item.node[name]))
for child in children:
name = child.node.nxname
if name not in item.node:
item.removeRow(child.row())
elif child.node is not item.node[name]:
item.removeRow(child.row())
item.appendRow(NXTreeItem(item.node[name]))
item.node.set_unchanged()
def status_message(self, message):
if isinstance(message, NXfield) or isinstance(message, NXgroup):
text = message._str_name()+' '+message._str_attrs()
elif isinstance(message, NXlink):
text = message._str_name()
else:
text = str(message)
self.mainwindow.statusBar().showMessage(text.replace('\n','; '))
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
import pkg_resources
import six
from nexusformat.nexus import (NeXusError, NXdata, NXentry, NXfield, NXgroup,
NXlink, NXroot, nxload)
from .pyqt import QtCore, QtGui, QtWidgets
from .utils import display_message, natural_sort, modification_time
from nexusformat.nexus import *
class NXtree(NXgroup):
"""
NXtree group. This is a subclass of the NXgroup class.
It is used as the invisible root item for NeXpy tree views.
"""
_model = None
_view = None
_item = None
_shell = {}
_attrs = {}
def __init__(self):
self._class = 'NXtree'
self._name = 'tree'
self._entries = {}
def accept(self):
name = self.get_name()
if self.class_name == "NXgroup":
nxclass = self.get_type()
if name:
self.node[name] = NXgroup(nxclass=nxclass)
else:
self.node.insert(NXgroup(nxclass=nxclass))
logging.info("'%s' added to '%s'"
% (self.node[name], self.node.nxpath))
elif name:
value = self.get_value()
dtype = self.get_type()
if value is not None:
if self.class_name == "NXfield":
self.node[name] = NXfield(value, dtype=dtype)
logging.info("'%s' added to '%s'"
% (name, self.node.nxpath))
units = self.get_units()
if units:
self.node[name].attrs['units'] = units
else:
self.node.attrs[name] = NXattr(value, dtype=dtype)
logging.info("Attribute '%s' added to '%s'"
def check_axis(self, node, axis):
if isinstance(node, NXgroup) or node.ndim > 1:
return False
axis_len = self.signal.shape[axis]
if node.ndim == 0:
node_len = 1
else:
node_len = node.shape[0]
if node_len == axis_len or node_len == axis_len+1:
return True
else:
return False
def accept(self):
name = self.get_name()
if self.class_name == "NXgroup":
nxclass = self.get_type()
if name:
self.node[name] = NXgroup(nxclass=nxclass)
else:
self.node.insert(NXgroup(nxclass=nxclass))
logging.info("'%s' added to '%s'"
% (self.node[name], self.node.nxpath))
elif name:
value = self.get_value()
dtype = self.get_type()
if value is not None:
if self.class_name == "NXfield":
self.node[name] = NXfield(value, dtype=dtype)
logging.info("'%s' added to '%s'"
% (name, self.node.nxpath))
units = self.get_units()
if units:
self.node[name].attrs['units'] = units
else: