def accept(self): if not self._selected: raise NeXusError("Need to select output file before saving") elif self.root.nxfilemode == 'r': raise NeXusError("NeXus file is locked") if self.overwrite: for entry in [e for e in self.root if e != 'entry']: reduce = NXReduce(self.root[entry], copy=True, overwrite=True) reduce.nxcopy() else: raise NeXusError("Much check 'overwrite' to save parameters") super(CopyDialog, self).accept()
def main(): parser = argparse.ArgumentParser( description="Copy instrument parameters from a parent file") parser.add_argument('-d', '--directory', required=True, help='scan directory') parser.add_argument('-e', '--entries', default=['f1', 'f2', 'f3'], nargs='+', help='names of entries to be searched') parser.add_argument('-p', '--parent', help='file name of file to copy from') parser.add_argument('-o', '--overwrite', action='store_true', help='overwrite existing peaks') parser.add_argument('-q', '--queue', action='store_true', help='add to server task queue') args = parser.parse_args() for entry in args.entries: reduce = NXReduce(entry, args.directory, parent=args.parent, copy=True, overwrite=args.overwrite) if args.queue: reduce.queue() else: reduce.nxcopy()