예제 #1
0
 def testIsResourceMarker(self):
     resource = [[1, 2, 3], ['a', 'b', 'c'],
                 resource_printer_base.PageMarker(), [7, 8, 9],
                 ['x', 'y', 'z'],
                 resource_printer_base.FinishMarker()]
     expected = [False, False, True, False, False, True]
     actual = []
     for record in resource:
         actual.append(resource_printer_base.IsResourceMarker(record))
     self.assertEqual(expected, actual)
예제 #2
0
  def Tap(self, resource):
    """Returns True if resource matches the filter expression.

    Args:
      resource: The resource to filter.

    Returns:
      True if resource matches the filter expression.
    """
    if resource_printer_base.IsResourceMarker(resource):
      return True
    return self._match(resource_projector.MakeSerializable(resource))
예제 #3
0
  def Tap(self, resource):
    """Returns True if the limit has not been reached yet, None otherwise.

    Args:
      resource: The resource to limit.

    Returns:
      True if the limit has not been reached yet, None otherwise to stop
      iterations.
    """
    if resource_printer_base.IsResourceMarker(resource):
      return True
    self._count += 1
    return self._count <= self._limit or None
예제 #4
0
  def Tap(self, resource):
    """Replaces resource with its URI or skips the resource if it has no URI.

    Args:
      resource: The resource to replace with its URI.

    Returns:
      TapInjector(URI, replace=True) if the resource has a URI or False to skip
      the resource.
    """
    if resource_printer_base.IsResourceMarker(resource):
      return True
    uri = self._transform_uri(resource, undefined=None)
    if not uri:
      return False
    return peek_iterable.TapInjector(uri, replace=True)
예제 #5
0
    def Tap(self, resource):
        """Returns True if resource matches the filter expression.

    Args:
      resource: The resource to filter.

    Returns:
      True if resource matches the filter expression.
    """
        self._missing_keys -= set(
            key for key in self._missing_keys
            if resource_property.ResourceContainsKey(resource, key))
        if resource_printer_base.IsResourceMarker(resource):
            return True
        return self._compiled_expression.Evaluate(
            resource_projector.MakeSerializable(resource))
예제 #6
0
  def Tap(self, resource):
    """Injects a PageMarker if the current page limit has been reached.

    Args:
      resource: The resource to limit.

    Returns:
      TapInjector(PageMarker) if the page current page limit has been reached,
      otherwise True to retain the current resource.
    """
    if resource_printer_base.IsResourceMarker(resource):
      return True
    self._count += 1
    if self._count > self._page_size:
      self._count = 0
      return peek_iterable.TapInjector(resource_printer_base.PageMarker())
    return True
예제 #7
0
  def Tap(self, resource):
    """Appends the URI for resource to the list of cache changes.

    Sets self._uris to None if a URI could not be retrieved for any resource.

    Args:
      resource: The resource from which the URI is extracted.

    Returns:
      True - all resources are seen downstream.
    """
    if resource_printer_base.IsResourceMarker(resource):
      return True
    if self._uris is not None:
      uri = self._transform_uri(resource, undefined=None)
      if uri:
        self._uris.append(uri)
      else:
        self._uris = None
    return True