code: def fileobj(path_or_file, mode='r'):
      
      if isinstance(path_or_file, six.string_types):
          try:
              return open(path_or_file, mode)
          except IOError:
              log = logging.getLogger('sos')
              log.debug("fileobj: %s could not be opened" % path_or_file)
              return closing(six.StringIO())
      else:
          return closing(path_or_file)
docs: Returns a file-like object that can be used as a context manager