Skip to content

Commit

Permalink
Return None if no vertices in Bounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
daspecster committed Sep 14, 2016
1 parent e4d4974 commit f75f96d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion google/cloud/vision/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def from_api_repr(cls, response):
:rtype: :class:`~google.cloud.vision.entiy.EntityAnnotation`
:returns: Instance of ``EntityAnnotation``.
"""
bounds = Bounds.from_api_repr(response.get('boundingPoly', {}))
bounds = Bounds.from_api_repr(response.get('boundingPoly'))
description = response['description']
locations = [LocationInformation.from_api_repr(location)
for location in response.get('locations', [])]
Expand Down
7 changes: 5 additions & 2 deletions google/cloud/vision/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ def from_api_repr(cls, response_vertices):
:type response_vertices: dict
:param response_vertices: List of vertices.
:rtype: :class:`~google.cloud.vision.geometry.BoundsBase`
:returns: Instance of BoundsBase with populated verticies.
:rtype: :class:`~google.cloud.vision.geometry.BoundsBase` or None
:returns: Instance of BoundsBase with populated verticies or None.
"""
if not response_vertices:
return None

vertices = [Vertex(vertex.get('x', None), vertex.get('y', None)) for
vertex in response_vertices.get('vertices', [])]
return cls(vertices)
Expand Down

0 comments on commit f75f96d

Please sign in to comment.