Skip to content

Commit 4b2f3a9

Browse files
committed
Merge pull request #207 from dhermes/indent-four-spaces
Indenting four spaces in all files.
2 parents 97278d8 + aa73c17 commit 4b2f3a9

26 files changed

+3241
-3223
lines changed

gcloud/connection.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@
22

33

44
class Connection(object):
5-
"""A generic connection to Google Cloud Platform.
5+
"""A generic connection to Google Cloud Platform.
66
7-
Subclasses should understand
8-
only the basic types
9-
in method arguments,
10-
however they should be capable
11-
of returning advanced types.
12-
"""
7+
Subclasses should understand
8+
only the basic types
9+
in method arguments,
10+
however they should be capable
11+
of returning advanced types.
12+
"""
1313

14-
API_BASE_URL = 'https://www.googleapis.com'
15-
"""The base of the API call URL."""
14+
API_BASE_URL = 'https://www.googleapis.com'
15+
"""The base of the API call URL."""
1616

17-
_EMPTY = object()
18-
"""A pointer to represent an empty value for default arguments."""
17+
_EMPTY = object()
18+
"""A pointer to represent an empty value for default arguments."""
1919

20-
def __init__(self, credentials=None):
21-
"""
22-
:type credentials: :class:`gcloud.credentials.Credentials`
23-
:param credentials: The OAuth2 Credentials to use for this connection.
24-
"""
20+
def __init__(self, credentials=None):
21+
""":type credentials: :class:`gcloud.credentials.Credentials`
22+
:param credentials: The OAuth2 Credentials to use for this connection.
2523
26-
self._credentials = credentials
24+
"""
2725

28-
@property
29-
def credentials(self):
30-
return self._credentials
26+
self._credentials = credentials
3127

32-
@property
33-
def http(self):
34-
"""A getter for the HTTP transport used in talking to the API.
28+
@property
29+
def credentials(self):
30+
return self._credentials
3531

36-
:rtype: :class:`httplib2.Http`
37-
:returns: A Http object used to transport data.
38-
"""
39-
if not hasattr(self, '_http'):
40-
self._http = httplib2.Http()
41-
if self._credentials:
42-
self._http = self._credentials.authorize(self._http)
43-
return self._http
32+
@property
33+
def http(self):
34+
"""A getter for the HTTP transport used in talking to the API.
35+
36+
:rtype: :class:`httplib2.Http`
37+
:returns: A Http object used to transport data.
38+
"""
39+
if not hasattr(self, '_http'):
40+
self._http = httplib2.Http()
41+
if self._credentials:
42+
self._http = self._credentials.authorize(self._http)
43+
return self._http

gcloud/credentials.py

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,38 @@
44

55

66
class Credentials(object):
7-
"""An object used to simplify the OAuth2 credentials library.
8-
9-
.. note::
10-
You should not need to use this class directly.
11-
Instead, use the helper methods provided in
12-
:func:`gcloud.datastore.__init__.get_connection`
13-
and
14-
:func:`gcloud.datastore.__init__.get_dataset`
15-
which use this class under the hood.
16-
"""
17-
18-
@classmethod
19-
def get_for_service_account(cls, client_email, private_key_path, scope=None):
20-
"""Gets the credentials for a service account.
21-
22-
:type client_email: string
23-
:param client_email: The e-mail attached to the service account.
24-
25-
:type private_key_path: string
26-
:param private_key_path: The path to a private key file (this file was
27-
given to you when you created the service
28-
account).
29-
30-
:type scope: string or tuple of strings
31-
:param scope: The scope against which to authenticate.
32-
(Different services require different scopes,
33-
check the documentation for which scope is required
34-
for the different levels of access
35-
to any particular API.)
7+
"""An object used to simplify the OAuth2 credentials library.
8+
9+
.. note::
10+
You should not need to use this class directly.
11+
Instead, use the helper methods provided in
12+
:func:`gcloud.datastore.__init__.get_connection`
13+
and
14+
:func:`gcloud.datastore.__init__.get_dataset`
15+
which use this class under the hood.
3616
"""
37-
return client.SignedJwtAssertionCredentials(
38-
service_account_name=client_email,
39-
private_key=open(private_key_path).read(),
40-
scope=scope)
17+
18+
@classmethod
19+
def get_for_service_account(cls, client_email, private_key_path,
20+
scope=None):
21+
"""Gets the credentials for a service account.
22+
23+
:type client_email: string
24+
:param client_email: The e-mail attached to the service account.
25+
26+
:type private_key_path: string
27+
:param private_key_path: The path to a private key file (this file was
28+
given to you when you created the service
29+
account).
30+
31+
:type scope: string or tuple of strings
32+
:param scope: The scope against which to authenticate.
33+
(Different services require different scopes,
34+
check the documentation for which scope is required
35+
for the different levels of access
36+
to any particular API.)
37+
"""
38+
return client.SignedJwtAssertionCredentials(
39+
service_account_name=client_email,
40+
private_key=open(private_key_path).read(),
41+
scope=scope)

gcloud/datastore/__init__.py

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
which represents a lookup or search over the rows in the datastore.
3333
"""
3434

35-
3635
__version__ = '0.1.2'
3736

3837
SCOPE = ('https://www.googleapis.com/auth/datastore ',
@@ -41,65 +40,65 @@
4140

4241

4342
def get_connection(client_email, private_key_path):
44-
"""Shortcut method to establish a connection to the Cloud Datastore.
43+
"""Shortcut method to establish a connection to the Cloud Datastore.
4544
46-
Use this if you are going to access several datasets
47-
with the same set of credentials (unlikely):
45+
Use this if you are going to access several datasets
46+
with the same set of credentials (unlikely):
4847
49-
>>> from gcloud import datastore
50-
>>> connection = datastore.get_connection(email, key_path)
51-
>>> dataset1 = connection.dataset('dataset1')
52-
>>> dataset2 = connection.dataset('dataset2')
48+
>>> from gcloud import datastore
49+
>>> connection = datastore.get_connection(email, key_path)
50+
>>> dataset1 = connection.dataset('dataset1')
51+
>>> dataset2 = connection.dataset('dataset2')
5352
54-
:type client_email: string
55-
:param client_email: The e-mail attached to the service account.
53+
:type client_email: string
54+
:param client_email: The e-mail attached to the service account.
5655
57-
:type private_key_path: string
58-
:param private_key_path: The path to a private key file (this file was
59-
given to you when you created the service
60-
account).
56+
:type private_key_path: string
57+
:param private_key_path: The path to a private key file (this file was
58+
given to you when you created the service
59+
account).
6160
62-
:rtype: :class:`gcloud.datastore.connection.Connection`
63-
:returns: A connection defined with the proper credentials.
64-
"""
65-
from gcloud.credentials import Credentials
66-
from gcloud.datastore.connection import Connection
61+
:rtype: :class:`gcloud.datastore.connection.Connection`
62+
:returns: A connection defined with the proper credentials.
63+
"""
64+
from gcloud.credentials import Credentials
65+
from gcloud.datastore.connection import Connection
6766

68-
credentials = Credentials.get_for_service_account(
69-
client_email, private_key_path, scope=SCOPE)
70-
return Connection(credentials=credentials)
67+
credentials = Credentials.get_for_service_account(
68+
client_email, private_key_path, scope=SCOPE)
69+
return Connection(credentials=credentials)
7170

7271

7372
def get_dataset(dataset_id, client_email, private_key_path):
74-
"""Establish a connection to a particular dataset in the Cloud Datastore.
75-
76-
This is a shortcut method for creating a connection and using it
77-
to connect to a dataset.
78-
79-
You'll generally use this as the first call to working with the API:
80-
81-
>>> from gcloud import datastore
82-
>>> dataset = datastore.get_dataset('dataset-id', email, key_path)
83-
>>> # Now you can do things with the dataset.
84-
>>> dataset.query().kind('TestKind').fetch()
85-
[...]
86-
87-
:type dataset_id: string
88-
:param dataset_id: The id of the dataset you want to use.
89-
This is akin to a database name
90-
and is usually the same as your Cloud Datastore project
91-
name.
92-
93-
:type client_email: string
94-
:param client_email: The e-mail attached to the service account.
95-
96-
:type private_key_path: string
97-
:param private_key_path: The path to a private key file (this file was
98-
given to you when you created the service
99-
account).
100-
101-
:rtype: :class:`gcloud.datastore.dataset.Dataset`
102-
:returns: A dataset with a connection using the provided credentials.
103-
"""
104-
connection = get_connection(client_email, private_key_path)
105-
return connection.dataset(dataset_id)
73+
"""Establish a connection to a particular dataset in the Cloud Datastore.
74+
75+
This is a shortcut method for creating a connection and using it
76+
to connect to a dataset.
77+
78+
You'll generally use this as the first call to working with the API:
79+
80+
>>> from gcloud import datastore
81+
>>> dataset = datastore.get_dataset('dataset-id', email, key_path)
82+
>>> # Now you can do things with the dataset.
83+
>>> dataset.query().kind('TestKind').fetch()
84+
[...]
85+
86+
:type dataset_id: string
87+
:param dataset_id: The id of the dataset you want to use.
88+
This is akin to a database name
89+
and is usually the same as your Cloud Datastore project
90+
name.
91+
92+
:type client_email: string
93+
:param client_email: The e-mail attached to the service account.
94+
95+
:type private_key_path: string
96+
:param private_key_path: The path to a private key file (this file was
97+
given to you when you created the service
98+
account).
99+
100+
:rtype: :class:`gcloud.datastore.dataset.Dataset`
101+
:returns: A dataset with a connection using the provided credentials.
102+
"""
103+
connection = get_connection(client_email, private_key_path)
104+
return connection.dataset(dataset_id)

0 commit comments

Comments
 (0)