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

Making prints Python 3 friendly. #2424

Merged
merged 1 commit into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ to activate Cloud Datastore for your project.
# Then query for entities
query = datastore.Query(kind='EntityKind')
for result in query.fetch():
print result
print(result)

Google Cloud Storage
--------------------
Expand Down Expand Up @@ -131,7 +131,7 @@ how to create a bucket.
bucket = client.get_bucket('bucket-id-here')
# Then do other things...
blob = bucket.get_blob('remote/path/to/file.txt')
print blob.download_as_string()
print(blob.download_as_string())
blob.upload_from_string('New contents!')
blob2 = bucket.blob('remote/path/storage.txt')
blob2.upload_from_filename(filename='/local/path.txt')
Expand Down Expand Up @@ -220,7 +220,7 @@ Perform a synchronous query
query.run()

for row in query.rows:
print row
print(row)


See the ``google-cloud-python`` API `BigQuery documentation`_ to learn how to connect
Expand Down Expand Up @@ -265,7 +265,7 @@ Example of fetching entries:

entries, token = logger.list_entries()
for entry in entries:
print entry.payload
print(entry.payload)

See the ``google-cloud-python`` API `logging documentation`_ to learn how to connect
to Stackdriver Logging using this Client Library.
Expand Down
2 changes: 1 addition & 1 deletion core/google/cloud/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_items_from_response(self, response):
requests)::

>>> for item in MyIterator(...):
>>> print item.name
>>> print(item.name)
>>> if not item.is_valid:
>>> break
"""
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/monitoring/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,21 +279,21 @@ def list_members(self, filter_string=None, end_time=None, start_time=None):
Example::

>>> for member in group.list_members():
... print member
... print(member)

List members that are Compute Engine VM instances::

>>> filter_string = 'resource.type = "gce_instance"'
>>> for member in group.list_members(filter_string=filter_string):
... print member
... print(member)

List historical members that existed between 4 and 5 hours ago::

>>> import datetime
>>> t1 = datetime.datetime.utcnow() - datetime.timedelta(hours=4)
>>> t0 = t1 - datetime.timedelta(hours=1)
>>> for member in group.list_members(end_time=t1, start_time=t0):
... print member
... print(member)


:type filter_string: string or None
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/resource_manager/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def list_projects(self, filter_params=None, page_size=None):
>>> from google.cloud import resource_manager
>>> client = resource_manager.Client()
>>> for project in client.list_projects():
... print project.project_id
... print(project.project_id)

List all projects with label ``'environment'`` set to ``'prod'``
(filtering by labels)::
Expand All @@ -113,7 +113,7 @@ def list_projects(self, filter_params=None, page_size=None):
>>> client = resource_manager.Client()
>>> env_filter = {'labels.environment': 'prod'}
>>> for project in client.list_projects(env_filter):
... print project.project_id
... print(project.project_id)

See:
https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/list
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_json_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def main():
os.path.join(JSON_DOCS_DIR, 'types.json'))
package_files(JSON_DOCS_DIR, DOCS_BUILD_DIR, BASE_JSON_DOCS_DIR)
if args.show_toc:
print json.dumps(toc, indent=4)
print(json.dumps(toc, indent=4))

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion storage/google/cloud/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
>>> bucket = client.get_bucket('bucket-id-here')
>>> # Then do other things...
>>> blob = bucket.get_blob('/remote/path/to/file.txt')
>>> print blob.download_as_string()
>>> print(blob.download_as_string())
>>> blob.upload_from_string('New contents!')
>>> blob2 = bucket.blob('/remote/path/storage.txt')
>>> blob2.upload_from_filename(filename='/local/path.txt')
Expand Down
2 changes: 1 addition & 1 deletion storage/google/cloud/storage/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
To get the list of ``entity`` and ``role`` for each unique pair, the
:class:`ACL` class is iterable::

>>> print list(ACL)
>>> print(list(ACL))
[{'role': 'OWNER', 'entity': 'allUsers'}, ...]

This list of tuples can be used as the ``entity`` and ``role`` fields
Expand Down
6 changes: 3 additions & 3 deletions storage/google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ def get_blob(self, blob_name, client=None):
>>> from google.cloud import storage
>>> client = storage.Client()
>>> bucket = client.get_bucket('my-bucket')
>>> print bucket.get_blob('/path/to/blob.txt')
>>> print(bucket.get_blob('/path/to/blob.txt'))
<Blob: my-bucket, /path/to/blob.txt>
>>> print bucket.get_blob('/does-not-exist.txt')
>>> print(bucket.get_blob('/does-not-exist.txt'))
None

:type blob_name: string
Expand Down Expand Up @@ -376,7 +376,7 @@ def delete_blob(self, blob_name, client=None):
>>> from google.cloud import storage
>>> client = storage.Client()
>>> bucket = client.get_bucket('my-bucket')
>>> print bucket.list_blobs()
>>> print(bucket.list_blobs())
[<Blob: my-bucket, my-file.txt>]
>>> bucket.delete_blob('my-file.txt')
>>> try:
Expand Down
10 changes: 5 additions & 5 deletions storage/google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_bucket(self, bucket_name):
>>> try:
>>> bucket = client.get_bucket('my-bucket')
>>> except google.cloud.exceptions.NotFound:
>>> print 'Sorry, that bucket does not exist!'
>>> print('Sorry, that bucket does not exist!')

This implements "storage.buckets.get".

Expand All @@ -174,10 +174,10 @@ def lookup_bucket(self, bucket_name):
than catching an exception::

>>> bucket = client.lookup_bucket('doesnt-exist')
>>> print bucket
>>> print(bucket)
None
>>> bucket = client.lookup_bucket('my-bucket')
>>> print bucket
>>> print(bucket)
<Bucket: my-bucket>

:type bucket_name: string
Expand All @@ -197,7 +197,7 @@ def create_bucket(self, bucket_name):
For example::

>>> bucket = client.create_bucket('my-bucket')
>>> print bucket
>>> print(bucket)
<Bucket: my-bucket>

This implements "storage.buckets.insert".
Expand All @@ -223,7 +223,7 @@ def list_buckets(self, max_results=None, page_token=None, prefix=None,
bucket.

>>> for bucket in client.list_buckets():
>>> print bucket
... print(bucket)

This implements "storage.buckets.list".

Expand Down