def GetFacter(self, open_fn=open):
    """Return facter contents.

    Args:
      open_fn: func, optional, supply an open() function
    Returns:
      dict, facter contents
    """
    if self.facter_cache_path is None:
      return {}

    if not os.path.isfile(self.facter_cache_path):
      logging.info('GetFacter: facter cache file does not exist.')
      return {}

    facter = {}
    use_facter_cache = False
    try:
      st = os.stat(self.facter_cache_path)
      # if we are root, and the writer of the cache was not root, OR
      # if we are not root, the cache was not written by root, and
      # the cache was not written by ourselves
      if (os.geteuid() == 0 and st.st_uid != 0) or (
          os.geteuid() != 0 and st.st_uid != 0 and os.geteuid() != st.st_uid):
        # don't trust this file.  be paranoid.
        logging.info('GetFacter: Untrusted facter cache, ignoring')
        use_facter_cache = False
      else:
        use_facter_cache = True
        cache_mtime = datetime.datetime.fromtimestamp(st.st_mtime)
        logging.debug('GetFacter: facter cache mtime is %s', cache_mtime)
    except OSError, e:
      logging.info('GetFacter: OSError from os.stat(): %s', str(e))
      use_facter_cache = False

    if use_facter_cache:
      try:
        logging.debug('GetFacter: reading recent facter cache')
        f = open_fn(self.facter_cache_path, 'r')
        facter = {}
        line = f.readline()
        while line:
          try:
            (key, unused_sep, value) = line.split(' ', 2)
            value = value.strip()
            facter[key] = value
          except ValueError:
            logging.info('GetFacter: ignoring facter cache line: %s', line)
          line = f.readline()
        f.close()
        logging.debug('GetFacter: read %d entities', len(facter))
      except (EOFError, __HOLE__), e:
        logging.warning('GetFacter: error %s', str(e))
        facter = {}

    return facter
dataset/ETHPy150Open google/simian/src/simian/client/client.py/HttpsAuthClient.GetFacter