code: def open_resource(source):
      
      try:
          return open(source, mode='rb')
      except (IOError, OSError) as err:
          try:
              resource = urlopen(source)
          except ValueError:
              pass
          else:
              resource.name = resource.url
              if hasattr(resource, '__enter__'):
                  return resource
              else:
                  return closing(resource)
          raise err
      except TypeError:
          if hasattr(source, 'read') and hasattr(source, 'readlines'):
              return source  # Source is already a file-like object
          raise
docs: Opens a resource in binary reading mode. Wraps the resource with a
      context manager when it doesn't have one.
  
      :param source: a filepath or an URL.