code: def _Open(self, path_spec=None, mode='rb'):
      
      if not self._file_object_set_in_init and not path_spec:
        raise ValueError('Missing path specification.')
  
      if not self._file_object_set_in_init:
        if not path_spec.HasParent():
          raise errors.PathSpecError(
              'Unsupported path specification without parent.')
  
        self._encryption_method = getattr(path_spec, 'encryption_method', None)
  
        if self._encryption_method is None:
          raise errors.PathSpecError(
              'Path specification missing encryption method.')
  
        self._file_object = resolver.Resolver.OpenFileObject(
            path_spec.parent, resolver_context=self._resolver_context)
  
      self._path_spec = path_spec
docs: Opens the file-like object.
  
      Args:
        path_spec (Optional[PathSpec]): path specification.
        mode (Optional[str]): file access mode.
  
      Raises:
        AccessError: if the access to open the file was denied.
        IOError: if the file-like object could not be opened.
        OSError: if the file-like object could not be opened.
        PathSpecError: if the path specification is incorrect.
        ValueError: if the path specification is invalid.