def get_name(self, filename): from nexpy.gui.consoleapp import _shell name = os.path.splitext(os.path.basename(filename))[0].replace(' ','_') name = "".join([c for c in name.replace('-','_') if c.isalpha() or c.isdigit() or c=='_']) if name in _shell.keys(): ind = [] for key in _shell.keys(): try: if key.startswith(name+'_'): ind.append(int(key[len(name)+1:])) except ValueError: pass if ind == []: ind = [0] name = name+'_'+str(sorted(ind)[-1]+1) return name
def get_name(self, filename): from nexpy.gui.consoleapp import _shell name = os.path.splitext(os.path.basename(filename))[0].replace( ' ', '_') name = "".join([ c for c in name.replace('-', '_') if c.isalpha() or c.isdigit() or c == '_' ]) if name in _shell.keys(): ind = [] for key in _shell.keys(): try: if key.startswith(name + '_'): ind.append(int(key[len(name) + 1:])) except ValueError: pass if ind == []: ind = [0] name = name + '_' + str(sorted(ind)[-1] + 1) return name
def get_new_name(self): from nexpy.gui.consoleapp import _shell ind = [] for key in _shell.keys(): try: if key.startswith('w'): ind.append(int(key[1:])) except ValueError: pass if ind == []: ind = [0] return 'w'+str(sorted(ind)[-1]+1)
def get_new_name(self): from nexpy.gui.consoleapp import _shell ind = [] for key in _shell.keys(): try: if key.startswith('w'): ind.append(int(key[1:])) except ValueError: pass if ind == []: ind = [0] return 'w' + str(sorted(ind)[-1] + 1)
def add(self, node): from nexpy.gui.consoleapp import _shell if isinstance(node, NXroot): group = node for key in _shell.keys(): if id(_shell[key]) == id(group): group.nxname = key self[group.nxname] = group elif isinstance(node, NXgroup): group = NXroot(node) self[self.get_new_name()] = group else: raise NeXusError("Only a valid NXgroup can be added to the tree")