def GetRealPath(filename):
 if os.path.isabs(filename):
  return filename
 if (filename.startswith('./') or filename.startswith('../')):
  return os.path.abspath(filename)
 path = os.getenv('PATH', '')
 for directory in path.split(':'):
  tryname = os.path.join(directory, filename)
  if os.path.exists(tryname):
   if (not os.path.isabs(directory)):
    return os.path.abspath(tryname)
   return tryname
 if os.path.exists(filename):
  return os.path.abspath(filename)
 return None

def GetRealPath ( filename ) : if os . path . isabs ( filename ) : return filename if ( filename . startswith ( './' ) or filename . startswith ( '../' ) ) : return os . path . abspath ( filename ) path = os . getenv ( 'PATH' , '' ) for directory in path . split ( ':' ) : tryname = os . path . join ( directory , filename ) if os . path . exists ( tryname ) : if ( not os . path . isabs ( directory ) ) : return os . path . abspath ( tryname ) return tryname if os . path . exists ( filename ) : return os . path . abspath ( filename ) return None
given an executable filename .