Skip to content

Commit b3233aa

Browse files
committed
Rename alternate factories for clarity.
1 parent 1305e81 commit b3233aa

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

gcloud/datastore/_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def _get_value_from_value_pb(value_pb):
148148
result = naive.replace(tzinfo=pytz.utc)
149149

150150
elif value_pb.HasField('key_value'):
151-
result = _FACTORIES.get('Key_pb')(value_pb.key_value)
151+
result = _FACTORIES.get('Key_from_protobuf')(value_pb.key_value)
152152

153153
elif value_pb.HasField('boolean_value'):
154154
result = value_pb.boolean_value
@@ -166,7 +166,7 @@ def _get_value_from_value_pb(value_pb):
166166
result = value_pb.blob_value
167167

168168
elif value_pb.HasField('entity_value'):
169-
result = _FACTORIES.get('Entity_pb')(value_pb.entity_value)
169+
result = _FACTORIES.get('Entity_from_protobuf')(value_pb.entity_value)
170170

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

gcloud/datastore/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_entities(self, keys):
105105
entities = []
106106
for entity_pb in entity_pbs:
107107
entities.append(_helpers._FACTORIES.invoke(
108-
'Entity_pb', entity_pb, dataset=self))
108+
'Entity_from_protobuf', entity_pb, dataset=self))
109109
return entities
110110

111111

gcloud/datastore/entity.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def from_protobuf(cls, pb, dataset=None):
151151
:returns: The :class:`Entity` derived from the
152152
:class:`gcloud.datastore.datastore_v1_pb2.Entity`.
153153
"""
154-
key = _helpers._FACTORIES.invoke('Key_pb', pb.key, dataset=dataset)
154+
key = _helpers._FACTORIES.invoke(
155+
'Key_from_protobuf', pb.key, dataset=dataset)
155156
entity = cls.from_key(key)
156157

157158
for property_pb in pb.property:
@@ -223,7 +224,8 @@ def save(self):
223224
transaction.add_auto_id_entity(self)
224225

225226
if isinstance(key_pb, datastore_pb.Key):
226-
updated_key = _helpers._FACTORIES.invoke('Key_pb', key_pb, dataset)
227+
updated_key = _helpers._FACTORIES.invoke(
228+
'Key_from_protobuf', key_pb, dataset)
227229
# Update the path (which may have been altered).
228230
self._key = key.path(updated_key.path())
229231

@@ -253,4 +255,4 @@ def __repr__(self):
253255

254256

255257
_helpers._FACTORIES.register('Entity', Entity)
256-
_helpers._FACTORIES.register('Entity_pb', Entity.from_protobuf)
258+
_helpers._FACTORIES.register('Entity_from_protobuf', Entity.from_protobuf)

gcloud/datastore/key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,5 @@ def __repr__(self):
292292

293293

294294
_helpers._FACTORIES.register('Key', Key)
295-
_helpers._FACTORIES.register('Key_pb', Key.from_protobuf)
296-
_helpers._FACTORIES.register('Key_path', Key.from_path)
295+
_helpers._FACTORIES.register('Key_from_protobuf', Key.from_protobuf)
296+
_helpers._FACTORIES.register('Key_from_path', Key.from_path)

gcloud/datastore/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def ancestor(self, ancestor):
189189

190190
# If a list was provided, turn it into a Key.
191191
if isinstance(ancestor, list):
192-
ancestor = _helpers._FACTORIES.invoke('Key_path', *ancestor)
192+
ancestor = _helpers._FACTORIES.invoke('Key_from_path', *ancestor)
193193

194194
# If we don't have a Key value by now, something is wrong.
195195
if not isinstance(ancestor, _helpers._FACTORIES.get('Key')):
@@ -322,7 +322,7 @@ def fetch(self, limit=None):
322322
entity_pbs, end_cursor = query_results[:2]
323323

324324
self._cursor = end_cursor
325-
return [_helpers._FACTORIES.invoke('Entity_pb', entity,
325+
return [_helpers._FACTORIES.invoke('Entity_from_protobuf', entity,
326326
dataset=self.dataset())
327327
for entity in entity_pbs]
328328

gcloud/datastore/transaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def commit(self):
237237
key_pb = result.insert_auto_id_key[i]
238238
# We can ignore the 'dataset' parameter ecause we are only
239239
# creating a transient instance in order to copy its path.
240-
key = _helpers._FACTORIES.invoke('Key_pb', key_pb)
240+
key = _helpers._FACTORIES.invoke('Key_from_protobuf', key_pb)
241241
entity.key(entity.key().path(key.path()))
242242

243243
# Tell the connection that the transaction is over.

0 commit comments

Comments
 (0)