Changeset 3216 for trunk/GSASIIdataGUI.py
- Timestamp:
- Jan 7, 2018 9:06:19 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r3212 r3216 2407 2407 # find all the exporter files 2408 2408 if not self.exporterlist: # this only needs to be done once 2409 pathlist = sys.path 2410 filelist = [] 2411 for path in pathlist: 2412 for filename in glob.iglob(os.path.join(path,"G2export*.py")): 2413 filelist.append(filename) 2414 filelist = sorted(list(set(filelist))) # remove duplicates 2415 # go through the routines and import them, saving objects that 2416 # have export routines (method Exporter) 2417 for filename in filelist: 2418 path,rootname = os.path.split(filename) 2419 pkg = os.path.splitext(rootname)[0] 2420 # try: 2421 fp = None 2422 fp, fppath,desc = imp.find_module(pkg,[path,]) 2423 pkg = imp.load_module(pkg,fp,fppath,desc) 2424 for clss in inspect.getmembers(pkg): # find classes defined in package 2425 if clss[0].startswith('_'): continue 2426 if inspect.isclass(clss[1]): 2427 # check if we have the required methods 2428 for m in 'Exporter','loadParmDict': 2429 if not hasattr(clss[1],m): break 2430 if not callable(getattr(clss[1],m)): break 2431 else: 2432 exporter = clss[1](self) # create an export instance 2433 self.exporterlist.append(exporter) 2434 # except AttributeError: 2435 # print 'Import_'+errprefix+': Attribute Error'+str(filename) 2436 # pass 2437 # except ImportError: 2438 # print 'Import_'+errprefix+': Error importing file'+str(filename) 2439 # pass 2440 if fp: fp.close() 2409 self.exporterlist = G2fil.LoadExportRoutines(self) 2410 2441 2411 # Add submenu item(s) for each Exporter by its self-declared type (can be more than one) 2442 2412 for obj in self.exporterlist:
Note: See TracChangeset
for help on using the changeset viewer.