Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #223: marshal list values from protobufs #246

Merged
merged 4 commits into from
Oct 16, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Kowtow to pylint's over-fussy 'too-many-return-statements'.
Incorporates feedback from @dhermes.
  • Loading branch information
tseaver committed Oct 16, 2014
commit fc4353fb3a4bb64050365df02ddf03ff7f0a684d
20 changes: 10 additions & 10 deletions gcloud/datastore/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,35 @@ def _get_value_from_value_pb(value_pb):
:returns: The value provided by the Protobuf.
"""

result = None
if value_pb.HasField('timestamp_microseconds_value'):

This comment was marked as spam.

This comment was marked as spam.

microseconds = value_pb.timestamp_microseconds_value
naive = (datetime.utcfromtimestamp(0) +
timedelta(microseconds=microseconds))
return naive.replace(tzinfo=pytz.utc)
result = naive.replace(tzinfo=pytz.utc)

elif value_pb.HasField('key_value'):
return Key.from_protobuf(value_pb.key_value)
result = Key.from_protobuf(value_pb.key_value)

elif value_pb.HasField('boolean_value'):
return value_pb.boolean_value
result = value_pb.boolean_value

elif value_pb.HasField('double_value'):
return value_pb.double_value
result = value_pb.double_value

elif value_pb.HasField('integer_value'):
return value_pb.integer_value
result = value_pb.integer_value

elif value_pb.HasField('string_value'):
return value_pb.string_value
result = value_pb.string_value

elif value_pb.HasField('entity_value'):
return Entity.from_protobuf(value_pb.entity_value)
result = Entity.from_protobuf(value_pb.entity_value)

elif value_pb.list_value:
return [_get_value_from_value_pb(x) for x in value_pb.list_value]
result = [_get_value_from_value_pb(x) for x in value_pb.list_value]

else:
return None
return result


def _get_value_from_property_pb(property_pb):
Expand Down