def OnDropFiles(self, x, y, filenames): namepotential = filterOnExtensions(["odt"], filenames) if not self.parent.batchModeCheckbox.GetValue() or not self.parent.digest: #normal mode if namepotential: self.parent._importFile(namepotential[0]) else: #batch mode for fname in namepotential: interp, outDir = self.parent._lightImportFile(fname) outfname = fname.rsplit(os.path.sep, 1)[1].split(".")[0] + ".txt" print outDir, outfname write(outDir + os.path.sep + outfname, interp, self.parent.delim, self.parent.watching)
def OnDropFiles(self, x, y, filenames): """ """ namepotential = filterOnExtensions(["odt"], filenames) if not self.parent.batchModeCheckbox.GetValue( ) or not self.parent.digest: #normal mode if namepotential: self.parent._importFile(namepotential[0]) return 0 else: #batch mode for fname in namepotential: interp, outDir = self.parent._lightImportFile(fname) outfname = fname.rsplit(os.path.sep, 1)[1].split(".")[0] + ".txt" print(outDir, outfname) odtchomp.write(outDir + os.path.sep + outfname, interp, self.parent.delim, self.parent.watching) return 1
def OnDropFiles(self, x, y, filenames): oommf = filterOnExtensions(["omf","ovf","oef","ohf"], filenames) if not oommf or not (self.parent.doNumpy.GetValue() or self.parent.doMATLAB.GetValue()): return #You got dropped some bad files! global LASTPATH LASTPATH = os.path.dirname(oommf[0]) arrays, headers, extra = groupUnpack(oommf, SupportDialog("Decode in Progress", "Decoding...", maximum=len(oommf))) #One final step before we're done - let's try to sort based on the sim time #using a standard decorate-sort-undecorate, with a twist for the variable number of keys #Let's start by finding the original indices - making a copy is key originalTimeIndex = list(extra["SimTime"]) if len(set(extra["MIFSource"])) == 1: if not -1 in extra["SimTime"]: extra["SimTime"], arrays = zip(*sorted(zip(originalTimeIndex, arrays))) #Sadly, the cleverness ends here - the rest must be bruteforced. for key in extra: if not key == "SimTime": #We did that one. junk, extra[key] = zip(*sorted(zip(originalTimeIndex, extra[key]))) self.parent.gatherData(arrays, headers, extra)
def OnDropFiles(self, x, y, filenames): """ """ oommf = filterOnExtensions(["omf", "ovf", "oef", "ohf"], filenames) if not oommf or not (self.parent.doNumpy.GetValue() or self.parent.doMATLAB.GetValue()): return 0 #You got dropped some bad files! global LASTPATH LASTPATH = os.path.dirname(oommf[0]) arrays, headers, extra = self.groupUnpack( oommf, SupportDialog("Decode in Progress", "Decoding...", maximum=len(oommf))) #One final step before we're done - let's try to sort based on the sim time #using a standard decorate-sort-undecorate, with a twist for the variable number of keys #Let's start by finding the original indices - making a copy is key arrays, extra = oommfdecode.sortBySimTime(extra, arrays) self.parent.gatherData(arrays, headers, extra) return 1
def OnDropFiles(self, x, y, filenames): #Find OOMMF, then a config, then files oommf = filterOnExtensions(["tcl"], filenames) if oommf: #What did you DO? Only the last one counts! self.parent.locateOOMMF(oommf[-1]) config = filterOnExtensions(["conf", "config", "cnf"], filenames) if config: #Again, only the last conf file dropped counts. self.parent.locateConf(config[-1]) if not (self.parent.config and self.parent.OOMMFPath): return 0 #Try to save a lot of work - only do magic if OMF-type files were dropped. targets = filterOnExtensions(["omf","ovf","oef","ohf"], filenames) if not targets: return 0 #Save more work by verifying that the user actually wants to make some sort of thing. if not self.parent.doImages.GetValue() and not self.parent.doMovie.GetValue(): #Er... you don't want to do anything? return 0 #Convince user that everything is OK, and provide me with entertainment. #Set up a dialog box that will track progress. dial = self.initializeProgressBar(targets) #To avoid some Py2EXE funkiness, we may need to redirect stdin. #Figure out where it needs to go, and catch that. childstd = self.findStandardIn() #We are now in the danger zone where the progress bar can get locked, and we #are going to shield that with some top-level exception handling try: dial.workDone(SETUP_LOAD, "Checking for Movies") #The first thing to do is try to make movies - in some cases, this process will leave behind #the images we need, and we can skip the image step entirely. print("Entering movie mode.") if self.parent.doMovie.GetValue(): #Make some movies. This also hands off the progressDialog, so it can be updated. self.doMovies(targets, childstd, dial) #Finish making some movies. dial.workDone(CLEANUP_LOAD, "Doing Images") #Awkward short-circuit - If you made movies and they have the same magnification as the images, you get to keep the images! if self.parent.doMovie.GetValue() and self.parent.movieMagnifierSpin.GetValue() == self.parent.magnifierSpin.GetValue(): dial.finish() return 1 if self.parent.doImages.GetValue(): #Oh well, I guess you're stuck making images. Make them! self.doImages(targets, childstd, dial) dial.workDone(CLEANUP_LOAD, "All Done!") except Exception as e: wx.MessageBox('Unpacking error: ' + repr(e), "Error") print(e) finally: dial.finish() return 1
def OnDropFiles(self, x, y, filenames): #Find OOMMF, then a config, then files oommf = filterOnExtensions(["tcl"], filenames) if oommf: #What did you DO? Only the last one counts! self.parent.locateOOMMF(oommf[-1]) config = filterOnExtensions(["conf", "config", "cnf"], filenames) if config: #Again, only the last conf file dropped counts. self.parent.locateConf(config[-1]) if not (self.parent.config and self.parent.OOMMFPath): return #Try to save a lot of work - only do magic if OMF-type files were dropped. targets = filterOnExtensions(["omf","ovf","oef","ohf"], filenames) if not targets: return #Save more work by verifying that the user actually wants to make some sort of thing. if not self.parent.doImages.GetValue() and not self.parent.doMovie.GetValue(): #Er... you don't want to do anything? return #Convince user that everything is OK, and provide me with entertainment. #Set up a dialog box that will track progress. dial = self.initializeProgressBar(targets) #To avoid some Py2EXE funkiness, we may need to redirect stdin. #Figure out where it needs to go, and catch that. childstd = self.findStandardIn() #We are now in the danger zone where the progress bar can get locked, and we #are going to shield that with some top-level exception handling try: dial.workDone(SETUP_LOAD, "Checking for Movies") #The first thing to do is try to make movies - in some cases, this process will leave behind #the images we need, and we can skip the image step entirely. print "Entering movie mode." if self.parent.doMovie.GetValue(): #Make some movies. This also hands off the progressDialog, so it can be updated. self.doMovies(targets, childstd, dial) #Finish making some movies. dial.workDone(CLEANUP_LOAD, "Doing Images") #Awkward short-circuit - If you made movies and they have the same magnification as the images, you get to keep the images! if self.parent.doMovie.GetValue() and self.parent.movieMagnifierSpin.GetValue() == self.parent.magnifierSpin.GetValue(): dial.finish() return if self.parent.doImages.GetValue(): #Oh well, I guess you're stuck making images. Make them! self.doImages(targets, childstd, dial) dial.workDone(CLEANUP_LOAD, "All Done!") except Exception as e: wx.MessageBox('Unpacking error: ' + repr(e), "Error") print e finally: dial.finish()