Skip to content

Commit b8a989f

Browse files
Kevin LeyowKevin Leyow
authored andcommitted
Fixed long lines and some more pep8 errors.
1 parent f4902a8 commit b8a989f

File tree

13 files changed

+54
-39
lines changed

13 files changed

+54
-39
lines changed

gcloud/datastore/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def get_connection(client_email, private_key_path):
7171

7272

7373
def get_dataset(dataset_id, client_email, private_key_path):
74-
"""Shortcut method to establish a connection to a particular dataset in the Cloud Datastore.
74+
"""Shortcut method to establish a connection to a particular
75+
dataset in the Cloud Datastore.
7576
7677
You'll generally use this as the first call to working with the API:
7778

gcloud/datastore/connection.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def _request(self, dataset_id, method, data):
7272
"""
7373
headers = {
7474
'Content-Type': 'application/x-protobuf',
75-
'Content-Length': str(len(data)),
76-
}
75+
'Content-Length': str(len(data)), }
7776
headers, content = self.http.request(
7877
uri=self.build_api_url(dataset_id=dataset_id, method=method),
7978
method='POST', headers=headers, body=data)
@@ -99,7 +98,7 @@ def build_api_url(cls, dataset_id, method, base_url=None, api_version=None):
9998
10099
:type dataset_id: string
101100
:param dataset_id: The ID of the dataset to connect to.
102-
This is usually your project name in the cloud console.
101+
This is usually your project name in the cloud console.
103102
104103
:type method: string
105104
:param method: The API method to call (ie, runQuery, lookup, ...).
@@ -134,7 +133,7 @@ def dataset(self, *args, **kwargs):
134133
"""Factory method for Dataset objects.
135134
136135
:param args: All args and kwargs will be passed along to the
137-
:class:`gcloud.datastore.dataset.Dataset` initializer.
136+
:class:`gcloud.datastore.dataset.Dataset` initializer.
138137
139138
:rtype: :class:`gcloud.datastore.dataset.Dataset`
140139
:returns: A dataset object that will use this connection as its transport.
@@ -156,7 +155,8 @@ def begin_transaction(self, dataset_id, serializable=False):
156155
request = datastore_pb.BeginTransactionRequest()
157156

158157
if serializable:
159-
request.isolation_level = datastore_pb.BeginTransactionRequest.SERIALIZABLE
158+
request.isolation_level = (
159+
datastore_pb.BeginTransactionRequest.SERIALIZABLE)
160160
else:
161161
request.isolation_level = datastore_pb.BeginTransactionRequest.SNAPSHOT
162162

@@ -226,7 +226,8 @@ def run_query(self, dataset_id, query_pb, namespace=None):
226226
request.partition_id.namespace = namespace
227227

228228
request.query.CopyFrom(query_pb)
229-
response = self._rpc(dataset_id, 'runQuery', request, datastore_pb.RunQueryResponse)
229+
response = self._rpc(dataset_id, 'runQuery', request,
230+
datastore_pb.RunQueryResponse)
230231
return [e.entity for e in response.batch.entity_result]
231232

232233
def lookup(self, dataset_id, key_pbs):

gcloud/datastore/demo/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
__all__ = ['get_dataset', 'CLIENT_EMAIL', 'DATASET_ID', 'PRIVATE_KEY_PATH']
66

77

8-
CLIENT_EMAIL = '754762820716-gimou6egs2hq1rli7el2t621a1b04t9i@developer.gserviceaccount.com'
8+
CLIENT_EMAIL = ('754762820716-gimou6egs2hq1rli7el2t621a1b04t9i'
9+
'@developer.gserviceaccount.com')
910
DATASET_ID = 'gcloud-datastore-demo'
1011
PRIVATE_KEY_PATH = os.path.join(os.path.dirname(__file__), 'demo.key')
1112

gcloud/datastore/entity.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,22 @@ class Entity(dict):
4343
>>> dataset.entity('MyEntityKind')
4444
<Entity[{'kind': 'MyEntityKind'}] {}>
4545
46-
- :func:`gcloud.datastore.dataset.Dataset.get_entity` to retrive an existing entity.
46+
- :func:`gcloud.datastore.dataset.Dataset.get_entity`
47+
to retrive an existing entity.
4748
4849
>>> dataset.get_entity(key)
4950
<Entity[{'kind': 'EntityKind', id: 1234}] {'property': 'value'}>
5051
51-
You can the set values on the entity just like you would on any other dictionary.
52+
You can the set values on the entity
53+
just like you would on any other dictionary.
5254
5355
>>> entity['age'] = 20
5456
>>> entity['name'] = 'JJ'
5557
>>> entity
5658
<Entity[{'kind': 'EntityKind', id: 1234}] {'age': 20, 'name': 'JJ'}>
5759
58-
And you can cast an entity to a regular Python dictionary with the `dict` builtin:
60+
And you can cast an entity to a regular Python dictionary
61+
with the `dict` builtin:
5962
6063
>>> dict(entity)
6164
{'age': 20, 'name': 'JJ'}
@@ -68,7 +71,8 @@ def __init__(self, dataset=None, kind=None):
6871
self._key = None
6972

7073
def dataset(self):
71-
"""Get the :class:`gcloud.datastore.dataset.Dataset` in which this entity belonds.
74+
"""Get the :class:`gcloud.datastore.dataset.Dataset`
75+
in which this entity belonds.
7276
7377
.. note::
7478
This is based on the :class:`gcloud.datastore.key.Key` set on the entity.
@@ -116,12 +120,14 @@ def kind(self):
116120

117121
@classmethod
118122
def from_key(cls, key):
119-
"""Factory method for creating an entity based on the :class:`gcloud.datastore.key.Key`.
123+
"""Factory method for creating an entity based on the
124+
:class:`gcloud.datastore.key.Key`.
120125
121126
:type key: :class:`gcloud.datastore.key.Key`
122127
:param key: The key for the entity.
123128
124-
:returns: The :class:`Entity` derived from the :class:`gcloud.datastore.key.Key`.
129+
:returns: The :class:`Entity` derived from the
130+
:class:`gcloud.datastore.key.Key`.
125131
"""
126132

127133
return cls().key(key)
@@ -135,7 +141,8 @@ def from_protobuf(cls, pb, dataset=None):
135141
:type key: :class:`gcloud.datastore.datastore_v1_pb2.Entity`
136142
:param key: The Protobuf representing the entity.
137143
138-
:returns: The :class:`Entity` derived from the :class:`gcloud.datastore.datastore_v1_pb2.Entity`.
144+
:returns: The :class:`Entity` derived from the
145+
:class:`gcloud.datastore.datastore_v1_pb2.Entity`.
139146
"""
140147

141148
# This is here to avoid circular imports.

gcloud/datastore/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ class Query(object):
4646
'<=': datastore_pb.PropertyFilter.LESS_THAN_OR_EQUAL,
4747
'>': datastore_pb.PropertyFilter.GREATER_THAN,
4848
'>=': datastore_pb.PropertyFilter.GREATER_THAN_OR_EQUAL,
49-
'=': datastore_pb.PropertyFilter.EQUAL,
50-
}
49+
'=': datastore_pb.PropertyFilter.EQUAL, }
5150
"""Mapping of operator strings and their protobuf equivalents."""
5251

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

6564
def to_protobuf(self):
66-
"""Convert the :class:`Query` instance to a :class:`gcloud.datastore.datastore_v1_pb2.Query`.
65+
"""Convert the :class:`Query` instance to a
66+
:class:`gcloud.datastore.datastore_v1_pb2.Query`.
6767
6868
:rtype: :class:`gclouddatstore.datastore_v1_pb2.Query`
6969
:returns: A Query protobuf that can be sent to the protobuf API.

gcloud/storage/acl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ def save(self):
379379

380380

381381
class DefaultObjectACL(BucketACL):
382-
"""A subclass of BucketACL representing the default object ACL for a bucket."""
382+
"""A subclass of BucketACL representing the
383+
default object ACL for a bucket."""
383384

384385
def save(self):
385386
"""Save this ACL as the default object ACL for the current bucket."""

gcloud/storage/bucket.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def get_all_keys(self):
102102
return list(self)
103103

104104
def new_key(self, key):
105-
"""Given a path name (or a Key), return a :class:`gcloud.storage.key.Key` object.
105+
"""Given a path name (or a Key), return a :class:`gcloud.storage.key.Key`
106+
object.
106107
107108
This is really useful when you're not sure
108109
if you have a Key object or a string path name.

gcloud/storage/connection.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ def generate_signed_url(self, resource, expiration,
464464
expiration = int(time.mktime(expiration.timetuple()))
465465

466466
if not isinstance(expiration, (int, long)):
467-
raise ValueError('Expected an integer timestamp, datetime, or timedelta. '
468-
'Got %s' % type(expiration))
467+
raise ValueError('Expected an integer timestamp, datetime, or '
468+
'timedelta. Got %s' % type(expiration))
469469

470470
# Generate the string to sign.
471471
signature_string = '\n'.join([
@@ -476,7 +476,8 @@ def generate_signed_url(self, resource, expiration,
476476
resource])
477477

478478
# Take our PKCS12 (.p12) key and make it into a RSA key we can use...
479-
pkcs12 = crypto.load_pkcs12(base64.b64decode(self.credentials.private_key), 'notasecret')
479+
pkcs12 = crypto.load_pkcs12(base64.b64decode(self.credentials.private_key),
480+
'notasecret')
480481
pem = crypto.dump_privatekey(crypto.FILETYPE_PEM, pkcs12.get_privatekey())
481482
pem_key = RSA.importKey(pem)
482483

gcloud/storage/demo/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
__all__ = ['get_connection', 'CLIENT_EMAIL', 'PRIVATE_KEY_PATH', 'PROJECT']
66

77

8-
CLIENT_EMAIL = '606734090113-6ink7iugcv89da9sru7lii8bs3i0obqg@developer.gserviceaccount.com'
8+
CLIENT_EMAIL = ('606734090113-6ink7iugcv89da9sru7lii8bs3i0obqg@'
9+
'developer.gserviceaccount.com')
910
PRIVATE_KEY_PATH = os.path.join(os.path.dirname(__file__), 'demo.key')
1011
PROJECT = 'gcloud-storage-demo'
1112

gcloud/storage/iterator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ def __init__(self, connection):
146146
super(BucketIterator, self).__init__(connection=connection, path='/b')
147147

148148
def get_items_from_response(self, response):
149-
"""Factory method which yields :class:`gcloud.storage.bucket.Bucket` items from a response.
149+
"""Factory method which yields :class:`gcloud.storage.bucket.Bucket`
150+
items from a response.
150151
151152
:type response: dict
152153
:param response: The JSON API response for a page of buckets.
@@ -174,7 +175,8 @@ def __init__(self, bucket):
174175
connection=bucket.connection, path=bucket.path + '/o')
175176

176177
def get_items_from_response(self, response):
177-
"""Factory method which yields :class:`gcloud.storage.key.Key` items from a response.
178+
"""Factory method which yields :class:`gcloud.storage.key.Key`
179+
items from a response.
178180
179181
:type response: dict
180182
:param response: The JSON API response for a page of keys.

0 commit comments

Comments
 (0)