code: def _open(file_or_str, **kwargs):
      '''Either open a file handle, or use an existing file-like object.
  
      This will behave as the `open` function if `file_or_str` is a string.
  
      If `file_or_str` has the `read` attribute, it will return `file_or_str`.
  
      Otherwise, an `IOError` is raised.
      '''
      if hasattr(file_or_str, 'read'):
          yield file_or_str
      elif isinstance(file_or_str, six.string_types):
          with open(file_or_str, **kwargs) as file_desc:
              yield file_desc
      else:
          raise IOError('Invalid file-or-str object: {}'.format(file_or_str)f _open(file_or_str, **kwargs):
      '''Either open a file handle, or use an existing file-like object.
  
      This will behave as the `open` function if `file_or_str` is a string.
  
      If `file_or_str` has the `read` attribute, it will return `file_or_str`.
  
      Otherwise, an `IOError` is raised.
      '''
      if hasattr(file_or_str, 'read'):
          yield file_or_str
      elif isinstance(file_or_str, six.string_types):
          with open(file_or_str, **kwargs) as file_desc:
              yield file_desc
      else:
          raise IOError('Invalid file-or-str object: {}'.format(file_or_str))
docs: Either open a file handle, or use an existing file-like object.
  
      This will behave as the `open` function if `file_or_str` is a string.
  
      If `file_or_str` has the `read` attribute, it will return `file_or_str`.
  
      Otherwise, an `IOError` is raised.