def _get_next_target(self, location):
        """ Return the next UI target from the given location.

        Parameters
        ----------
        location : instance of locator type
            A location for resolving the next target.

        Returns
        -------
        new_target : any

        Raises
        ------
        LocationNotSupport
            If no solver are provided for resolving the given location in the
            wrapped UI target.
        """
        supported = set()
        for registry in self._registries:
            try:
                handler = registry.get_solver(
                    self.target.__class__,
                    location.__class__,
                )
            except LocationNotSupported as e:
                supported |= set(e.supported)
            else:
                return handler(self, location)

        raise LocationNotSupported(
            target_class=self.target.__class__,
            locator_class=location.__class__,
            supported=list(supported),
        )
    def _get_location_doc(self, target, locator_class):
        """ Return the documentation for the given target and locator type.

        This is an implementation for an abstract method.

        Parameters
        ----------
        target : any
            The UI target being operated on.
        locator_class : subclass of type
            Any class.

        Returns
        -------
        doc : str

        Raises
        ------
        LocationNotSupported
            If the given locator and target types are not supported.
        """
        raise LocationNotSupported(
            target_class=target.__class__,
            locator_class=locator_class,
            supported=[],
        )
Exemple #3
0
 def _get_solver(self, target, location):
     if location.__class__ not in self.supported_locator_classes:
         raise LocationNotSupported(
             target_class=target.__class__,
             locator_class=location.__class__,
             supported=list(self.supported_locator_classes),
         )
     return self.solver
Exemple #4
0
 def __init__(self):
     self._interaction_registry = _TargetToKeyRegistry(
         exception_maker=(lambda target_class, key, available_keys:
                          (InteractionNotSupported(
                              target_class=target_class,
                              interaction_class=key,
                              supported=available_keys,
                          ))), )
     self._location_registry = _TargetToKeyRegistry(exception_maker=(
         lambda target_class, key, available_keys: LocationNotSupported(
             target_class=target_class,
             locator_class=key,
             supported=available_keys,
         )), )
    def _get_solver(self, target, location):
        """ Return a callable registered for resolving a location for the
        given target and location.

        This is an implementation for an abstract method.

        Parameters
        ----------
        target : any
            The UI target being operated on.
        location : subclass of type
            The location to be resolved on the target.

        Raises
        ------
        LocationNotSupported
            If the given locator and target types are not supported.
        """
        raise LocationNotSupported(
            target_class=target.__class__,
            locator_class=location.__class__,
            supported=[],
        )
 def get_solver(self, target_class, locator_class):
     raise LocationNotSupported(
         target_class=None,
         locator_class=None,
         supported=[float],
     )