Skip to content

Instantly share code, notes, and snippets.

@daspecster
Created January 19, 2017 21:01
Show Gist options
  • Save daspecster/a59f15324f9d353343fc137b3c451bda to your computer and use it in GitHub Desktop.
Save daspecster/a59f15324f9d353343fc137b3c451bda to your computer and use it in GitHub Desktop.
# non-ternary; fails coverage
def _make_image_properties_from_pb(image_properties):
"""Create ``ImageProperties`` object from a protobuf response.
:type image_properties: :class:`~google.cloud.grpc.vision.v1.\
image_annotator_pb2.ImagePropertiesAnnotation`
:param image_properties: Protobuf instance of
``ImagePropertiesAnnotation``.
:rtype: list
:returns: List of ``ImageProperties``.
"""
properties = ImagePropertiesAnnotation.from_pb(image_properties)
if properties is not None:
return [properties]
# ternary; passes coverage
def _make_image_properties_from_pb(image_properties):
"""Create ``ImageProperties`` object from a protobuf response.
:type image_properties: :class:`~google.cloud.grpc.vision.v1.\
image_annotator_pb2.ImagePropertiesAnnotation`
:param image_properties: Protobuf instance of
``ImagePropertiesAnnotation``.
:rtype: list
:returns: List of ``ImageProperties``.
"""
properties = ImagePropertiesAnnotation.from_pb(image_properties)
return [properties] if properties else None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment