def onRead(self, path): if path in self.controller.file_groups: if wx.ID_YES != popup(self, "Re-read file '%s'?" % path, 'Re-read file?'): return filedir, filename = os.path.split(path) pref = fix_varname(filename.replace('.', '_')) if len(pref) > 15: pref = pref[:15] groupname = pref count, maxcount = 0, 999 while hasattr(self.larch.symtable, groupname) and count < maxcount: count += 1 groupname = '%s_%2.2i' % (pref, count) if self.config['chdir_on_fileopen']: os.chdir(filedir) kwargs = dict(filename=path, _larch=self.larch_buffer.larchshell, last_array_sel=self.last_array_sel, read_ok_cb=self.onRead_OK) # check for athena projects if is_athena_project(path): self.show_subframe('athena_import', AthenaImporter, **kwargs) else: self.show_subframe('readfile', ColumnDataFileFrame, **kwargs)
def onRead(self, path): if path in self.controller.file_groups: if wx.ID_YES != popup(self, "Re-read file '%s'?" % path, 'Re-read file?'): return filedir, filename = os.path.split(path) pref= fix_varname(filename.replace('.', '_')) if len(pref) > 15: pref = pref[:15] groupname = pref count, maxcount = 0, 999 while hasattr(self.larch.symtable, groupname) and count < maxcount: count += 1 groupname = '%s_%2.2i' % (pref, count) if self.config['chdir_on_fileopen']: os.chdir(filedir) # check for athena projects if is_athena_project(path): self.show_subframe('athena_import', AthenaImporter, filename=path, _larch=self.larch, read_ok_cb=partial(self.onRead_OK, overwrite=False)) return ## not athena, plain ASCII: fh = open(path, 'r') line1 = fh.readline().lower() fh.close() reader = read_ascii if 'epics stepscan file' in line1: reader = read_gsexdi elif 'epics scan' in line1: reader = gsescan_group elif 'xdi' in line1: reader = read_xdi dgroup = reader(str(path), _larch=self.larch) if reader == gsescan_group: assign_gsescan_groups(dgroup) dgroup.path = path dgroup.filename = filename dgroup.groupname = groupname self.show_subframe('coledit', EditColumnFrame, group=dgroup, last_array_sel=self.last_array_sel, _larch=self.larch, read_ok_cb=partial(self.onRead_OK, overwrite=False))
def onReadData(self, event=None): wildcard = 'Data file (*.dat)|*.dat|All files (*.*)|*.*' dlg = wx.FileDialog(self, message='Open Data File', defaultDir=os.getcwd(), wildcard=FILE_WILDCARDS, style=wx.FD_OPEN|wx.FD_CHANGE_DIR) path = None if dlg.ShowModal() == wx.ID_OK: path = os.path.abspath(dlg.GetPath()).replace('\\', '/') dlg.Destroy() if path is None: return if is_athena_project(path): self.show_subframe(name='athena_import', filename=path, creator=AthenaImporter, read_ok_cb=self.onReadAthenaProject_OK) else: filedir, filename = os.path.split(path) pref = fix_varname((filename + '_'*8)[:8]).replace('.', '_').lower() count, maxcount = 1, 9999 groupname = "%s%3.3i" % (pref, count) while hasattr(self.larchshell.symtable, groupname) and count < maxcount: count += 1 groupname = '%s%3.3i' % (pref, count) fh = open(path, 'r') line1 = fh.readline().lower() fh.close() reader = read_ascii if 'epics stepscan file' in line1: reader = read_gsexdi elif 'epics scan' in line1: reader = gsescan_group elif 'xdi' in line1: reader = read_xdi dgroup = reader(str(path), _larch=self.larchshell._larch) dgroup._path = path dgroup._filename = filename dgroup._groupname = groupname self.show_subframe(name='coledit', event=None, creator=ColumnDataFileFrame, filename=path, last_array_sel=self.last_array_sel, read_ok_cb=self.onReadScan_Success)
def onRead(self, path): filedir, filename = os.path.split(path) if self.controller.get_config('chdir_on_fileopen'): os.chdir(filedir) self.controller.set_workdir() # check for athena projects if is_athena_project(path): kwargs = dict(filename=path, _larch=self.controller.larch, read_ok_cb=self.onReadAthenaProject_OK) self.show_subframe('athena_import', AthenaImporter, **kwargs) else: kwargs = dict(filename=path, _larch=self.larch_buffer.larchshell, last_array_sel=self.last_array_sel, read_ok_cb=self.onRead_OK) self.show_subframe('readfile', ColumnDataFileFrame, **kwargs)
def onRead(self, path): filedir, filename = os.path.split(path) if self.controller.get_config('chdir_on_fileopen'): os.chdir(filedir) self.controller.set_workdir() # check for athena projects if is_athena_project(path): kwargs = dict(filename=path, _larch = self.controller.larch, read_ok_cb=self.onReadAthenaProject_OK) self.show_subframe('athena_import', AthenaImporter, **kwargs) else: kwargs = dict(filename=path, _larch=self.larch_buffer.larchshell, last_array_sel = self.last_array_sel, read_ok_cb=self.onRead_OK) self.show_subframe('readfile', ColumnDataFileFrame, **kwargs)