Changeset 469
- Timestamp:
- Feb 3, 2012 2:55:41 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 19 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r468 r469 17 17 import time 18 18 import copy 19 import glob 20 import imp 21 import inspect 19 22 import numpy as np 20 23 import scipy as sp … … 78 81 ] = [wx.NewId() for _init_coll_Data_Items in range(10)] 79 82 80 [wxID_IMPORT, wxID_IMPORTPATTERN, wxID_IMPORTHKL, wxID_IMPORTPHASE, 81 wxID_IMPORTCIF, wxID_IMPORTPDB, 82 ] = [wx.NewId() for _init_coll_Import_Items in range(6)] 83 [wxID_IMPORT, wxID_IMPORTPATTERN, wxID_IMPORTHKL 84 #, wxID_IMPORTPHASE, 85 #wxID_IMPORTCIF, wxID_IMPORTPDB, 86 ] = [wx.NewId() for _init_coll_Import_Items in range(3)] 83 87 84 88 [wxID_EXPORT, wxID_EXPORTPATTERN, wxID_EXPORTHKL, wxID_EXPORTPHASE, … … 165 169 self.Bind(wx.EVT_MENU, self.OnSolve, id=wxID_SOLVE) 166 170 171 def _init_Import_Phase(self,parent): 172 '''import all the G2importphase*.py files that are found in the 173 path and configure the Import Phase menus accordingly 174 ''' 175 176 path2GSAS2 = os.path.dirname(os.path.realpath(__file__)) # location of this file 177 pathlist = sys.path[:] 178 if path2GSAS2 not in pathlist: pathlist.append(path2GSAS2) 179 filelist = [] 180 for path in pathlist: 181 for filename in glob.iglob(os.path.join(path, "G2importphase*.py")): 182 filelist.append(filename) 183 #print 'found',filename 184 filelist = sorted(list(set(filelist))) # remove duplicates 185 self.ImportPhaseReaderlist = [] 186 for filename in filelist: 187 path,rootname = os.path.split(filename) 188 pkg = os.path.splitext(rootname)[0] 189 try: 190 fp = None 191 fp, fppath,desc = imp.find_module(pkg,[path,]) 192 pkg = imp.load_module(pkg,fp,fppath,desc) 193 for clss in inspect.getmembers(pkg): # find classes defined in package 194 if clss[0].startswith('_'): continue 195 if inspect.isclass(clss[1]): 196 # check if we have the required methods 197 for m in 'Reader','ExtensionValidator','ContentsValidator': 198 if not hasattr(clss[1],m): break 199 if not callable(getattr(clss[1],m)): break 200 else: 201 reader = clss[1]() # create a phase import instance 202 self.ImportPhaseReaderlist.append(reader) 203 except AttributeError: 204 print 'Import_Phase: Attribute Error',filename 205 pass 206 except ImportError: 207 print 'Import_Phase: Error importing file',filename 208 pass 209 finally: 210 if fp: fp.close() 211 item = parent.Append(wx.ID_ANY, help='Import phase data', 212 kind=wx.ITEM_NORMAL,text='Import Phase (generic)...') 213 self.Bind(wx.EVT_MENU, self.OnImportPhaseGeneric, id=item.GetId()) 214 submenu = wx.Menu() 215 item = parent.AppendMenu(wx.ID_ANY, 'Import Phase (specific)', 216 submenu, 217 help='Import phase data') 218 self.PhaseImportMenuId = {} 219 for reader in self.ImportPhaseReaderlist: 220 item = submenu.Append(wx.ID_ANY, 221 help='Import specific format phase data', 222 kind=wx.ITEM_NORMAL, 223 text='Import Phase '+reader.formatName+'...') 224 self.PhaseImportMenuId[item.GetId()] = reader 225 self.Bind(wx.EVT_MENU, self.OnImportPhaseGeneric, id=item.GetId()) 226 227 def OnImportPhaseGeneric(self,event): 228 # find out which format was requested 229 reader = self.PhaseImportMenuId.get(event.GetId()) 230 if reader is None: 231 #print "use all formats" 232 readerlist = self.ImportPhaseReaderlist 233 choices = "any file (*.*)|*.*" 234 extdict = {} 235 # compile a list of allowed extensions 236 for rd in readerlist: 237 fmt = rd.formatName 238 for extn in rd.extensionlist: 239 if not extdict.get(extn): extdict[extn] = [] 240 extdict[extn] += [fmt,] 241 for extn in sorted(extdict.keys(), 242 cmp=lambda x,y: cmp(x.lower(), y.lower())): 243 fmt = '' 244 for f in extdict[extn]: 245 if fmt != "": fmt += ', ' 246 fmt += f 247 choices += "|" + fmt + " file (*" + extn + ")|*" + extn 248 else: 249 readerlist = [reader,] 250 # compile a list of allowed extensions 251 choices = reader.formatName + " file (" 252 w = "" 253 for extn in reader.extensionlist: 254 if w != "": w += ";" 255 w += "*" + extn 256 choices += w + ")|" + w 257 if not reader.strictExtension: 258 choices += "|any file (*.*)|*.*" 259 # get the file 260 dlg = wx.FileDialog( 261 self, message="Choose phase input file", 262 #defaultDir=os.getcwd(), 263 defaultFile="", 264 wildcard=choices, 265 style=wx.OPEN | wx.CHANGE_DIR 266 ) 267 try: 268 if dlg.ShowModal() == wx.ID_OK: 269 file = dlg.GetPath() 270 else: # cancel was pressed 271 return 272 finally: 273 dlg.Destroy() 274 # set what formats are compatible with this file 275 primaryReaders = [] 276 secondaryReaders = [] 277 for reader in readerlist: 278 flag = reader.ExtensionValidator(file) 279 if flag is None: 280 secondaryReaders.append(reader) 281 elif flag: 282 primaryReaders.append(reader) 283 if len(secondaryReaders) + len(primaryReaders) == 0: 284 self.ErrorDialog('No matching format for file '+file,'No Format') 285 return 286 287 fp = None 288 try: 289 fp = open(file,'r') 290 # try the file first with Readers that specify the 291 # files extension and later with ones that allow it 292 for rd in primaryReaders+secondaryReaders: 293 if not rd.ContentsValidator(fp): 294 continue # rejected on cursory check 295 #flag = rd.Reader(file,fp,self) 296 try: 297 flag = rd.Reader(file,fp,self) 298 except: 299 self.ErrorDialog('Error reading file '+file 300 +' with format '+ rd.formatName, 301 'Read Error') 302 continue 303 if not flag: continue 304 dlg = wx.TextEntryDialog( # allow editing of phase name 305 self, 'Enter the name for the new phase', 306 'Edit phase name', rd.Phase['General']['Name'], 307 style=wx.OK) 308 #dlg.SetValue("Python is the best!") 309 dlg.CenterOnParent() 310 if dlg.ShowModal() == wx.ID_OK: 311 rd.Phase['General']['Name'] = dlg.GetValue() 312 dlg.Destroy() 313 PhaseName = rd.Phase['General']['Name'] 314 if not G2gd.GetPatternTreeItemId(self,self.root,'Phases'): 315 sub = self.PatternTree.AppendItem(parent=self.root,text='Phases') 316 else: 317 sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases') 318 psub = self.PatternTree.AppendItem(parent=sub,text=PhaseName) 319 self.PatternTree.SetItemPyData(psub,rd.Phase) 320 self.PatternTree.Expand(self.root) # make sure phases are seen 321 self.PatternTree.Expand(sub) 322 self.PatternTree.Expand(psub) 323 return # success 324 except: 325 self.ErrorDialog('Error on open of file '+file,'Open Error') 326 finally: 327 if fp: fp.close() 328 329 return 330 331 167 332 def _init_coll_Import_Items(self,parent): 168 self.ImportPhase = parent.Append(help='Import phase data from GSAS EXP file',169 id=wxID_IMPORTPHASE, kind=wx.ITEM_NORMAL,text='Import GSAS EXP Phase...')170 self.ImportPDB = parent.Append(help='Import phase data from PDB file',171 id=wxID_IMPORTPDB, kind=wx.ITEM_NORMAL,text='Import PDB Phase...')172 self.ImportCIF = parent.Append(help='Import phase data from cif file',id=wxID_IMPORTCIF, kind=wx.ITEM_NORMAL,173 text='Import CIF Phase...')333 # self.ImportPhase = parent.Append(help='Import phase data from GSAS EXP file', 334 # id=wxID_IMPORTPHASE, kind=wx.ITEM_NORMAL,text='Import GSAS EXP Phase...') 335 # self.ImportPDB = parent.Append(help='Import phase data from PDB file', 336 # id=wxID_IMPORTPDB, kind=wx.ITEM_NORMAL,text='Import PDB Phase...') 337 # self.ImportCIF = parent.Append(help='Import phase data from cif file',id=wxID_IMPORTCIF, kind=wx.ITEM_NORMAL, 338 # text='Import CIF Phase...') 174 339 self.ImportPattern = parent.Append(help='',id=wxID_IMPORTPATTERN, kind=wx.ITEM_NORMAL, 175 340 text='Import Powder Pattern...') 176 341 self.ImportHKL = parent.Append(help='',id=wxID_IMPORTHKL, kind=wx.ITEM_NORMAL, 177 342 text='Import HKLs...') 178 self.Bind(wx.EVT_MENU, self.OnImportPhase, id=wxID_IMPORTPHASE)179 self.Bind(wx.EVT_MENU, self.OnImportPDB, id=wxID_IMPORTPDB)180 self.Bind(wx.EVT_MENU, self.OnImportCIF, id=wxID_IMPORTCIF)343 # self.Bind(wx.EVT_MENU, self.OnImportPhase, id=wxID_IMPORTPHASE) 344 # self.Bind(wx.EVT_MENU, self.OnImportPDB, id=wxID_IMPORTPDB) 345 # self.Bind(wx.EVT_MENU, self.OnImportCIF, id=wxID_IMPORTCIF) 181 346 self.Bind(wx.EVT_MENU, self.OnImportPattern, id=wxID_IMPORTPATTERN) 182 347 self.Bind(wx.EVT_MENU, self.OnImportHKL, id=wxID_IMPORTHKL) … … 220 385 self._init_coll_Data_Items(self.Data) 221 386 self._init_coll_Calculate_Items(self.Calculate) 387 self._init_Import_Phase(self.Import) 222 388 self._init_coll_Import_Items(self.Import) 223 389 self._init_coll_Export_Items(self.Export) … … 1177 1343 dlg.Destroy() 1178 1344 1345 ''' replaced -- delete soon 1179 1346 def OnImportPhase(self,event): 1180 1347 dlg = wx.FileDialog(self, 'Choose GSAS EXP file', '.', '', … … 1215 1382 1216 1383 def OnImportCIF(self,event): 1384 def ReadCIFPhase(filename): 1385 import random as ran 1386 import GSASIIlattice as G2lat 1387 anisoNames = ['aniso_u_11','aniso_u_22','aniso_u_33','aniso_u_12','aniso_u_13','aniso_u_23'] 1388 file = open(filename, 'Ur') 1389 Phase = {} 1390 Title = ospath.split(filename)[-1] 1391 print '\n Reading cif file: ',Title 1392 Compnd = '' 1393 Atoms = [] 1394 A = np.zeros(shape=(3,3)) 1395 S = file.readline() 1396 while S: 1397 if '_symmetry_space_group_name_H-M' in S: 1398 SpGrp = S.split("_symmetry_space_group_name_H-M")[1].strip().strip('"').strip("'") 1399 E,SGData = G2spc.SpcGroup(SpGrp) 1400 if E: 1401 print ' ERROR in space group symbol ',SpGrp,' in file ',filename 1402 print ' N.B.: make sure spaces separate axial fields in symbol' 1403 print G2spc.SGErrors(E) 1404 return None 1405 S = file.readline() 1406 elif '_cell' in S: 1407 if '_cell_length_a' in S: 1408 a = S.split('_cell_length_a')[1].strip().strip('"').strip("'").split('(')[0] 1409 elif '_cell_length_b' in S: 1410 b = S.split('_cell_length_b')[1].strip().strip('"').strip("'").split('(')[0] 1411 elif '_cell_length_c' in S: 1412 c = S.split('_cell_length_c')[1].strip().strip('"').strip("'").split('(')[0] 1413 elif '_cell_angle_alpha' in S: 1414 alp = S.split('_cell_angle_alpha')[1].strip().strip('"').strip("'").split('(')[0] 1415 elif '_cell_angle_beta' in S: 1416 bet = S.split('_cell_angle_beta')[1].strip().strip('"').strip("'").split('(')[0] 1417 elif '_cell_angle_gamma' in S: 1418 gam = S.split('_cell_angle_gamma')[1].strip().strip('"').strip("'").split('(')[0] 1419 S = file.readline() 1420 elif 'loop_' in S: 1421 labels = {} 1422 i = 0 1423 while S: 1424 S = file.readline() 1425 if '_atom_site' in S.strip()[:10]: 1426 labels[S.strip().split('_atom_site_')[1].lower()] = i 1427 i += 1 1428 else: 1429 break 1430 if labels: 1431 if 'aniso_label' not in labels: 1432 while S: 1433 atom = ['','','',0,0,0,1.0,'','','I',0.01,0,0,0,0,0,0] 1434 S.strip() 1435 if len(S.split()) != len(labels): 1436 if 'loop_' in S: 1437 break 1438 S += file.readline().strip() 1439 data = S.split() 1440 if len(data) != len(labels): 1441 break 1442 for key in labels: 1443 if key == 'type_symbol': 1444 atom[1] = data[labels[key]] 1445 elif key == 'label': 1446 atom[0] = data[labels[key]] 1447 elif key == 'fract_x': 1448 atom[3] = float(data[labels[key]].split('(')[0]) 1449 elif key == 'fract_y': 1450 atom[4] = float(data[labels[key]].split('(')[0]) 1451 elif key == 'fract_z': 1452 atom[5] = float(data[labels[key]].split('(')[0]) 1453 elif key == 'occupancy': 1454 atom[6] = float(data[labels[key]].split('(')[0]) 1455 elif key == 'thermal_displace_type': 1456 if data[labels[key]].lower() == 'uiso': 1457 atom[9] = 'I' 1458 atom[10] = float(data[labels['u_iso_or_equiv']].split('(')[0]) 1459 else: 1460 atom[9] = 'A' 1461 atom[10] = 0.0 1462 1463 atom[7],atom[8] = G2spc.SytSym(atom[3:6],SGData) 1464 atom.append(ran.randint(0,sys.maxint)) 1465 Atoms.append(atom) 1466 S = file.readline() 1467 else: 1468 while S: 1469 S.strip() 1470 data = S.split() 1471 if len(data) != len(labels): 1472 break 1473 name = data[labels['aniso_label']] 1474 for atom in Atoms: 1475 if name == atom[0]: 1476 for i,uname in enumerate(anisoNames): 1477 atom[i+11] = float(data[labels[uname]].split('(')[0]) 1478 S = file.readline() 1479 1480 else: 1481 S = file.readline() 1482 file.close() 1483 if Title: 1484 PhaseName = Title 1485 else: 1486 PhaseName = 'None' 1487 SGlines = G2spc.SGPrint(SGData) 1488 for line in SGlines: print line 1489 cell = [float(a),float(b),float(c),float(alp),float(bet),float(gam)] 1490 Volume = G2lat.calc_V(G2lat.cell2A(cell)) 1491 Phase['General'] = {'Name':PhaseName,'Type':'nuclear','SGData':SGData, 1492 'Cell':[False,]+cell+[Volume,]} 1493 Phase['Atoms'] = Atoms 1494 Phase['Drawing'] = {} 1495 Phase['Histograms'] = {} 1496 1497 return Phase 1498 1217 1499 dlg = wx.FileDialog(self, 'Choose CIF file', '.', '', 1218 1500 'CIF file (*.cif)|*.cif',wx.OPEN|wx.CHANGE_DIR) … … 1220 1502 if dlg.ShowModal() == wx.ID_OK: 1221 1503 CIFfile = dlg.GetPath() 1222 Phase = G2IO.ReadCIFPhase(CIFfile)1504 Phase = ReadCIFPhase(CIFfile) 1223 1505 finally: 1224 1506 dlg.Destroy() … … 1230 1512 sub = G2gd.GetPatternTreeItemId(self,self.root,'Phases') 1231 1513 sub = self.PatternTree.AppendItem(parent=sub,text=PhaseName) 1232 self.PatternTree.SetItemPyData(sub,Phase) 1233 1514 self.PatternTree.SetItemPyData(sub,Phase) 1515 print Phase 1516 ''' 1517 1234 1518 def OnExportPatterns(self,event): 1235 1519 names = ['All'] -
trunk/GSASIIIO.py
r468 r469 1565 1565 1566 1566 return Phase 1567 1568 def ReadCIFPhase(filename): 1569 anisoNames = ['aniso_u_11','aniso_u_22','aniso_u_33','aniso_u_12','aniso_u_13','aniso_u_23'] 1570 file = open(filename, 'Ur') 1571 Phase = {} 1572 Title = ospath.split(filename)[-1] 1573 print '\n Reading cif file: ',Title 1574 Compnd = '' 1575 Atoms = [] 1576 A = np.zeros(shape=(3,3)) 1577 S = file.readline() 1578 while S: 1579 if '_symmetry_space_group_name_H-M' in S: 1580 SpGrp = S.split("_symmetry_space_group_name_H-M")[1].strip().strip('"').strip("'") 1581 E,SGData = G2spc.SpcGroup(SpGrp) 1582 if E: 1583 print ' ERROR in space group symbol ',SpGrp,' in file ',filename 1584 print ' N.B.: make sure spaces separate axial fields in symbol' 1585 print G2spc.SGErrors(E) 1586 return None 1587 S = file.readline() 1588 elif '_cell' in S: 1589 if '_cell_length_a' in S: 1590 a = S.split('_cell_length_a')[1].strip().strip('"').strip("'").split('(')[0] 1591 elif '_cell_length_b' in S: 1592 b = S.split('_cell_length_b')[1].strip().strip('"').strip("'").split('(')[0] 1593 elif '_cell_length_c' in S: 1594 c = S.split('_cell_length_c')[1].strip().strip('"').strip("'").split('(')[0] 1595 elif '_cell_angle_alpha' in S: 1596 alp = S.split('_cell_angle_alpha')[1].strip().strip('"').strip("'").split('(')[0] 1597 elif '_cell_angle_beta' in S: 1598 bet = S.split('_cell_angle_beta')[1].strip().strip('"').strip("'").split('(')[0] 1599 elif '_cell_angle_gamma' in S: 1600 gam = S.split('_cell_angle_gamma')[1].strip().strip('"').strip("'").split('(')[0] 1601 S = file.readline() 1602 elif 'loop_' in S: 1603 labels = {} 1604 i = 0 1605 while S: 1606 S = file.readline() 1607 if '_atom_site' in S.strip()[:10]: 1608 labels[S.strip().split('_atom_site_')[1].lower()] = i 1609 i += 1 1610 else: 1611 break 1612 if labels: 1613 if 'aniso_label' not in labels: 1614 while S: 1615 atom = ['','','',0,0,0,1.0,'','','I',0.01,0,0,0,0,0,0] 1616 S.strip() 1617 if len(S.split()) != len(labels): 1618 if 'loop_' in S: 1619 break 1620 S += file.readline().strip() 1621 data = S.split() 1622 if len(data) != len(labels): 1623 break 1624 for key in labels: 1625 if key == 'type_symbol': 1626 atom[1] = data[labels[key]] 1627 elif key == 'label': 1628 atom[0] = data[labels[key]] 1629 elif key == 'fract_x': 1630 atom[3] = float(data[labels[key]].split('(')[0]) 1631 elif key == 'fract_y': 1632 atom[4] = float(data[labels[key]].split('(')[0]) 1633 elif key == 'fract_z': 1634 atom[5] = float(data[labels[key]].split('(')[0]) 1635 elif key == 'occupancy': 1636 atom[6] = float(data[labels[key]].split('(')[0]) 1637 elif key == 'thermal_displace_type': 1638 if data[labels[key]].lower() == 'uiso': 1639 atom[9] = 'I' 1640 atom[10] = float(data[labels['u_iso_or_equiv']].split('(')[0]) 1641 else: 1642 atom[9] = 'A' 1643 atom[10] = 0.0 1644 1645 atom[7],atom[8] = G2spc.SytSym(atom[3:6],SGData) 1646 atom.append(ran.randint(0,sys.maxint)) 1647 Atoms.append(atom) 1648 S = file.readline() 1649 else: 1650 while S: 1651 S.strip() 1652 data = S.split() 1653 if len(data) != len(labels): 1654 break 1655 name = data[labels['aniso_label']] 1656 for atom in Atoms: 1657 if name == atom[0]: 1658 for i,uname in enumerate(anisoNames): 1659 atom[i+11] = float(data[labels[uname]].split('(')[0]) 1660 S = file.readline() 1661 1662 else: 1663 S = file.readline() 1664 file.close() 1665 if Title: 1666 PhaseName = Title 1667 else: 1668 PhaseName = 'None' 1669 SGlines = G2spc.SGPrint(SGData) 1670 for line in SGlines: print line 1671 cell = [float(a),float(b),float(c),float(alp),float(bet),float(gam)] 1672 Volume = G2lat.calc_V(G2lat.cell2A(cell)) 1673 Phase['General'] = {'Name':PhaseName,'Type':'nuclear','SGData':SGData, 1674 'Cell':[False,]+cell+[Volume,]} 1675 Phase['Atoms'] = Atoms 1676 Phase['Drawing'] = {} 1677 Phase['Histograms'] = {} 1678 1679 return Phase 1680 1567 1568 ###################################################################### 1569 # base classes for reading various types of data files 1570 # not used directly, only by subclassing 1571 ###################################################################### 1572 E,SGData = G2spc.SpcGroup('P 1') # data structure for default space group 1573 class ImportPhase(object): 1574 '''Defines a base class for the reading of files with coordinates 1575 ''' 1576 def __init__(self, 1577 formatName, 1578 longFormatName=None, 1579 extensionlist=[], 1580 strictExtension=False, 1581 ): 1582 self.formatName = formatName # short string naming file type 1583 if longFormatName: # longer string naming file type 1584 self.longFormatName = longFormatName 1585 else: 1586 self.longFormatName = formatName 1587 # define extensions that are allowed for the file type 1588 # for windows, remove any extensions that are duplicate, if case is ignored 1589 if sys.platform == 'windows' and extensionlist: 1590 extensionlist = list(set([s.lower() for s in extensionlist])) 1591 self.extensionlist = extensionlist 1592 # If strictExtension is True, the file will not be read, unless 1593 # the extension matches one in the extensionlist 1594 self.strictExtension = strictExtension 1595 # define a default Phase structure 1596 self.Phase = {} 1597 for i in 'General', 'Atoms', 'Drawing', 'Histograms': 1598 self.Phase[i] = {} 1599 self.Phase['General']['Name'] = 'default' 1600 self.Phase['General']['Type'] = 'nuclear' 1601 self.Phase['General']['SGData'] = SGData 1602 self.Phase['General']['Cell'] = [ 1603 False, # refinement flag 1604 1.,1.,1., # a,b,c 1605 90.,90.,90., # alpha, beta, gamma 1606 1. # volume 1607 ] 1608 self.warnings = '' 1609 self.errors = '' 1610 #print 'created',self.__class__ 1611 1612 def PhaseSelector(self, ChoiceList, ParentFrame=None, 1613 title='Select a phase', size=None): 1614 ''' Provide a wx dialog to select a phase if the file contains more 1615 than one 1616 ''' 1617 dlg = wx.SingleChoiceDialog( 1618 ParentFrame, 1619 title, 1620 'Phase Selection', 1621 ChoiceList, 1622 ) 1623 if size: dlg.SetSize(size) 1624 if dlg.ShowModal() == wx.ID_OK: 1625 sel = dlg.GetSelection() 1626 dlg.Destroy() 1627 return sel 1628 else: 1629 dlg.Destroy() 1630 return None 1631 1632 def ShowBusy(self): 1633 wx.BeginBusyCursor() 1634 1635 def DoneBusy(self): 1636 wx.EndBusyCursor() 1637 1638 # def Reader(self, filename, filepointer, ParentFrame=None): 1639 # '''This method must be supplied in the child class 1640 # it will read the file 1641 # ''' 1642 # return True # if read OK 1643 # return False # if an error occurs 1644 1645 def ExtensionValidator(self, filename): 1646 '''This methods checks if the file has the correct extension 1647 Return False if this filename will not be supported by this reader 1648 Return True if the extension matches the list supplied by the reader 1649 Return None if the reader allows un-registered extensions 1650 ''' 1651 if filename: 1652 ext = os.path.splitext(filename)[1] 1653 if sys.platform == 'windows': ext = ext.lower() 1654 if ext in self.extensionlist: return True 1655 if self.strictExtension: return False 1656 return None 1657 1658 def ContentsValidator(self, filepointer): 1659 '''This routine will attempt to determine if the file can be read 1660 with the current format. 1661 This will typically be overridden with a method that 1662 takes a quick scan of [some of] 1663 the file contents to do a "sanity" check if the file 1664 appears to match the selected format. 1665 Expected to be called via self.Validator() 1666 ''' 1667 #filepointer.seek(0) # rewind the file pointer 1668 return True 1669
Note: See TracChangeset
for help on using the changeset viewer.