Skip to content

Commit

Permalink
Reverted summary lines and changed closing brackets for addibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Leyow authored and Kevin Leyow committed Sep 30, 2014
1 parent b8a989f commit f4fc666
Show file tree
Hide file tree
Showing 18 changed files with 239 additions and 124 deletions.
3 changes: 1 addition & 2 deletions gcloud/datastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ def get_connection(client_email, private_key_path):


def get_dataset(dataset_id, client_email, private_key_path):
"""Shortcut method to establish a connection to a particular
dataset in the Cloud Datastore.
"""Shortcut method to establish a connection to a particular dataset in the Cloud Datastore.
You'll generally use this as the first call to working with the API:
Expand Down
7 changes: 4 additions & 3 deletions gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def _request(self, dataset_id, method, data):
"""
headers = {
'Content-Type': 'application/x-protobuf',
'Content-Length': str(len(data)), }
'Content-Length': str(len(data)),
}
headers, content = self.http.request(
uri=self.build_api_url(dataset_id=dataset_id, method=method),
method='POST', headers=headers, body=data)
Expand All @@ -98,7 +99,7 @@ def build_api_url(cls, dataset_id, method, base_url=None, api_version=None):
:type dataset_id: string
:param dataset_id: The ID of the dataset to connect to.
This is usually your project name in the cloud console.
This is usually your project name in the cloud console.
:type method: string
:param method: The API method to call (ie, runQuery, lookup, ...).
Expand Down Expand Up @@ -133,7 +134,7 @@ def dataset(self, *args, **kwargs):
"""Factory method for Dataset objects.
:param args: All args and kwargs will be passed along to the
:class:`gcloud.datastore.dataset.Dataset` initializer.
:class:`gcloud.datastore.dataset.Dataset` initializer.
:rtype: :class:`gcloud.datastore.dataset.Dataset`
:returns: A dataset object that will use this connection as its transport.
Expand Down
3 changes: 2 additions & 1 deletion gcloud/datastore/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def get_entities(self, keys):

entity_pbs = self.connection().lookup(
dataset_id=self.id(),
key_pbs=[k.to_protobuf() for k in keys])
key_pbs=[k.to_protobuf() for k in keys]
)

entities = []
for entity_pb in entity_pbs:
Expand Down
14 changes: 6 additions & 8 deletions gcloud/datastore/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Entity(dict):
<Entity[{'kind': 'MyEntityKind'}] {}>
- :func:`gcloud.datastore.dataset.Dataset.get_entity`
to retrive an existing entity.
to retrive an existing entity.
>>> dataset.get_entity(key)
<Entity[{'kind': 'EntityKind', id: 1234}] {'property': 'value'}>
Expand All @@ -71,8 +71,7 @@ def __init__(self, dataset=None, kind=None):
self._key = None

def dataset(self):
"""Get the :class:`gcloud.datastore.dataset.Dataset`
in which this entity belonds.
"""Get the :class:`gcloud.datastore.dataset.Dataset` in which this entity belongs.
.. note::
This is based on the :class:`gcloud.datastore.key.Key` set on the entity.
Expand Down Expand Up @@ -120,14 +119,13 @@ def kind(self):

@classmethod
def from_key(cls, key):
"""Factory method for creating an entity based on the
:class:`gcloud.datastore.key.Key`.
"""Factory method for creating an entity based on the :class:`gcloud.datastore.key.Key`.
:type key: :class:`gcloud.datastore.key.Key`
:param key: The key for the entity.
:returns: The :class:`Entity` derived from the
:class:`gcloud.datastore.key.Key`.
:class:`gcloud.datastore.key.Key`.
"""

return cls().key(key)
Expand All @@ -139,10 +137,10 @@ def from_protobuf(cls, pb, dataset=None):
The protobuf should be one returned from the Cloud Datastore Protobuf API.
:type key: :class:`gcloud.datastore.datastore_v1_pb2.Entity`
:param key: The Protobuf representing the entity.
:param key: The Protobuf representing the entity.
:returns: The :class:`Entity` derived from the
:class:`gcloud.datastore.datastore_v1_pb2.Entity`.
:class:`gcloud.datastore.datastore_v1_pb2.Entity`.
"""

# This is here to avoid circular imports.
Expand Down
6 changes: 3 additions & 3 deletions gcloud/datastore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class Query(object):
'<=': datastore_pb.PropertyFilter.LESS_THAN_OR_EQUAL,
'>': datastore_pb.PropertyFilter.GREATER_THAN,
'>=': datastore_pb.PropertyFilter.GREATER_THAN_OR_EQUAL,
'=': datastore_pb.PropertyFilter.EQUAL, }
'=': datastore_pb.PropertyFilter.EQUAL,
}
"""Mapping of operator strings and their protobuf equivalents."""

def __init__(self, kind=None, dataset=None):
Expand All @@ -62,8 +63,7 @@ def _clone(self):
return clone

def to_protobuf(self):
"""Convert the :class:`Query` instance to a
:class:`gcloud.datastore.datastore_v1_pb2.Query`.
"""Convert the :class:`Query` instance to a :class:`gcloud.datastore.datastore_v1_pb2.Query`.
:rtype: :class:`gclouddatstore.datastore_v1_pb2.Query`
:returns: A Query protobuf that can be sent to the protobuf API.
Expand Down
8 changes: 6 additions & 2 deletions gcloud/datastore/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def test_it(self):
self.assertEqual(client._called_with,
{'service_account_name': CLIENT_EMAIL,
'private_key': PRIVATE_KEY,
'scope': SCOPE, })
'scope': SCOPE,
}
)


class Test_get_dataset(unittest2.TestCase):
Expand Down Expand Up @@ -61,4 +63,6 @@ def test_it(self):
self.assertEqual(client._called_with,
{'service_account_name': CLIENT_EMAIL,
'private_key': PRIVATE_KEY,
'scope': SCOPE, })
'scope': SCOPE,
}
)
Loading

0 comments on commit f4fc666

Please sign in to comment.