diff --git a/GSASII/GSASIIdataGUI.py b/GSASII/GSASIIdataGUI.py index d975517d..92bd7b24 100644 --- a/GSASII/GSASIIdataGUI.py +++ b/GSASII/GSASIIdataGUI.py @@ -1191,6 +1191,8 @@ def OnImportGeneric(self,reader,readerlist,label,multiple=False, rd.selections = [] rd.dnames = [] rd.ReInitialize() # purge anything from a previous read + if not Start: # reuse bank selections from 1st file + rd.selections = list(userSel) rd.errors = "" # clear out any old errors if not rd.ContentsValidator(filename): # rejected on cursory check errorReport += "\n "+rd.formatName + ' validator error' @@ -1202,6 +1204,7 @@ def OnImportGeneric(self,reader,readerlist,label,multiple=False, if dlg.ShowModal() == wx.ID_OK: rd.selections = dlg.GetSelections() Start = False + userSel = list(rd.selections) dlg.Destroy() repeat = True rdbuffer = {} # create temporary storage for file reader diff --git a/GSASII/GSASIIscriptable.py b/GSASII/GSASIIscriptable.py index b1d5bc52..d88934f5 100644 --- a/GSASII/GSASIIscriptable.py +++ b/GSASII/GSASIIscriptable.py @@ -482,7 +482,9 @@ def import_generic(filename, readerlist, fmthint=None, bank=None, for rd in primaryReaders + secondaryReaders: # Initialize reader - rd.selections = [] + rd.dnames = [] + rd.ReInitialize() + rd.useNet = useNet # matters only for phase importers if bank is None: rd.selections = [] else: @@ -490,18 +492,14 @@ def import_generic(filename, readerlist, fmthint=None, bank=None, rd.selections = [i-1 for i in bank] except TypeError: rd.selections = [bank-1] - rd.dnames = [] - rd.ReInitialize() - rd.useNet = useNet # matters only for phase importers - # Rewind file - rd.errors = "" + if any(i < 0 for i in rd.selections): + raise G2ImportException(f"Databank numbering starts at 1, got {bank}.") if not rd.ContentsValidator(filename): # Report error G2fil.G2Print("Warning: File {} has a validation error, continuing".format(filename)) #if len(rd.selections) > 1: # raise G2ImportException("File {} has {} banks. Specify which bank to read with databank param." # .format(filename,len(rd.selections))) - block = 0 if buffer is None: rdbuffer = {} diff --git a/GSASII/imports/G2pwd_GPX.py b/GSASII/imports/G2pwd_GPX.py index bec4017c..3aff1d0f 100644 --- a/GSASII/imports/G2pwd_GPX.py +++ b/GSASII/imports/G2pwd_GPX.py @@ -45,8 +45,8 @@ def ContentsValidator(self, filename): if nhist: if not len(self.selections): #no PWDR entries self.selections = range(nhist) - fp.close() - return True + fp.close() + return True self.errors = 'No powder entries found' fp.close() return False