def guess_prefix(directory=None):
 def check_candidate(path, directory=None):
  'Auxilliary function that checks whether a particular\n        path is a good candidate.\n\n        '
  candidate = os.path.join(path, 'share', 'ivre')
  if (directory is not None):
   candidate = os.path.join(candidate, directory)
  try:
   if stat.S_ISDIR(os.stat(candidate).st_mode):
    return candidate
  except OSError:
   pass
 if __file__.startswith('/'):
  path = '/'
  for elt in __file__.split('/')[1:]:
   if (elt in ['lib', 'lib32', 'lib64']):
    candidate = check_candidate(path, directory=directory)
    if (candidate is not None):
     return candidate
   path = os.path.join(path, elt)
 for path in ['/usr', '/usr/local', '/opt', '/opt/ivre']:
  candidate = check_candidate(path, directory=directory)
  if (candidate is not None):
   return candidate

def guess_prefix ( directory = None ) : def check_candidate ( path , directory = None ) : candidate = os . path . join ( path , 'share' , 'ivre' ) if ( directory is not None ) : candidate = os . path . join ( candidate , directory ) try : if stat . S_ISDIR ( os . stat ( candidate ) . st_mode ) : return candidate except OSError : pass if __file__ . startswith ( '/' ) : path = '/' for elt in __file__ . split ( '/' ) [ 1 : ] : if ( elt in [ 'lib' , 'lib32' , 'lib64' ] ) : candidate = check_candidate ( path , directory = directory ) if ( candidate is not None ) : return candidate path = os . path . join ( path , elt ) for path in [ '/usr' , '/usr/local' , '/opt' , '/opt/ivre' ] : candidate = check_candidate ( path , directory = directory ) if ( candidate is not None ) : return candidate
attempts to find the base directory where ivre components are installed .