def LocateFileName(fileNamesString, searchPaths):
 import regutil, string, os
 fileNames = string.split(fileNamesString, ';')
 for path in searchPaths:
  for fileName in fileNames:
   try:
    retPath = os.path.join(path, fileName)
    os.stat(retPath)
    break
   except os.error:
    retPath = None
  if retPath:
   break
 else:
  fileName = fileNames[0]
  try:
   import win32ui, win32con
  except ImportError:
   raise error, ('Need to locate the file %s, but the win32ui module is not available\nPlease run the program again, passing as a parameter the path to this file.' % fileName)
  flags = win32con.OFN_FILEMUSTEXIST
  ext = os.path.splitext(fileName)[1]
  filter = ('Files of requested type (*%s)|*%s||' % (ext, ext))
  dlg = win32ui.CreateFileDialog(1, None, fileName, flags, filter, None)
  dlg.SetOFNTitle(('Locate ' + fileName))
  if (dlg.DoModal() != win32con.IDOK):
   raise KeyboardInterrupt, 'User cancelled the process'
  retPath = dlg.GetPathName()
 return os.path.abspath(retPath)

def LocateFileName ( fileNamesString , searchPaths ) : import regutil , string , os fileNames = string . split ( fileNamesString , ';' ) for path in searchPaths : for fileName in fileNames : try : retPath = os . path . join ( path , fileName ) os . stat ( retPath ) break except os . error : retPath = None if retPath : break else : fileName = fileNames [ 0 ] try : import win32ui , win32con except ImportError : raise error , ( 'Need to locate the file %s, but the win32ui module is not available\nPlease run the program again, passing as a parameter the path to this file.' % fileName ) flags = win32con . OFN_FILEMUSTEXIST ext = os . path . splitext ( fileName ) [ 1 ] filter = ( 'Files of requested type (*%s)|*%s||' % ( ext , ext ) ) dlg = win32ui . CreateFileDialog ( 1 , None , fileName , flags , filter , None ) dlg . SetOFNTitle ( ( 'Locate ' + fileName ) ) if ( dlg . DoModal ( ) != win32con . IDOK ) : raise KeyboardInterrupt , 'User cancelled the process' retPath = dlg . GetPathName ( ) return os . path . abspath ( retPath )
locate a file name .