Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for subdirectory in ['backups', 'functions', 'plugins', 'readers',
'scripts']:
directory = os.path.join(nexpy_dir, subdirectory)
if not os.path.exists(directory):
os.mkdir(directory)
global _nexpy_dir
self.nexpy_dir = _nexpy_dir = nexpy_dir
self.backup_dir = os.path.join(self.nexpy_dir, 'backups')
self.plugin_dir = os.path.join(self.nexpy_dir, 'plugins')
self.reader_dir = os.path.join(self.nexpy_dir, 'readers')
self.script_dir = os.path.join(self.nexpy_dir, 'scripts')
self.function_dir = os.path.join(self.nexpy_dir, 'functions')
sys.path.append(self.function_dir)
self.scratch_file = os.path.join(self.nexpy_dir, 'w0.nxs')
if not os.path.exists(self.scratch_file):
NXroot().save(self.scratch_file)
def add(self, node):
if isinstance(node, NXgroup):
shell_names = self.get_shell_names(node)
if shell_names:
node.nxname = shell_names[0]
if isinstance(node, NXroot):
self[node.nxname] = node
self[node.nxname]._file_modified = False
elif isinstance(node, NXentry):
group = NXroot(node)
name = self.get_new_name()
self[name] = group
print("NeXpy: '%s' added to tree in '%s'" % (node.nxname,
group.nxname))
else:
group = NXroot(NXentry(node))
name = self.get_new_name()
self[name] = group
print("NeXpy: '%s' added to tree in '%s%s'" %
(node.nxname, group.nxname, node.nxgroup.nxpath))
else:
raise NeXusError("Only an NXgroup can be added to the tree")
self.mainwindow.default_action.setEnabled(False)
self.mainwindow.fit_action.setEnabled(False)
if node is None:
self.mainwindow.reload_action.setEnabled(False)
self.mainwindow.collapse_action.setEnabled(False)
self.mainwindow.view_action.setEnabled(False)
return
else:
self.mainwindow.reload_action.setEnabled(True)
self.mainwindow.collapse_action.setEnabled(True)
self.mainwindow.view_action.setEnabled(True)
if node.nxfilemode is None or node.nxfilemode == 'rw':
self.mainwindow.rename_action.setEnabled(True)
if not isinstance(node, NXlink):
self.mainwindow.add_action.setEnabled(True)
if isinstance(node, NXroot):
self.mainwindow.savefile_action.setEnabled(True)
self.mainwindow.remove_action.setEnabled(True)
if node.nxfilemode:
self.mainwindow.duplicate_action.setEnabled(True)
if node.nxfilemode == 'r':
self.mainwindow.unlockfile_action.setEnabled(True)
else:
self.mainwindow.lockfile_action.setEnabled(True)
self.mainwindow.backup_action.setEnabled(True)
if node.nxbackup:
self.mainwindow.restore_action.setEnabled(True)
if node.nxfilemode is None or node.nxfilemode == 'rw':
if self.mainwindow.copied_node is not None:
self.mainwindow.pastedata_action.setEnabled(True)
self.mainwindow.pastelink_action.setEnabled(True)
if node.nxfilemode is None:
def reload(self, name):
if name in self:
if isinstance(self[name], NXroot):
self[name].reload()
return self[name]
else:
raise NeXusError('%s not in the tree')