Skip to content

Commit be52e91

Browse files
committed
Merge pull request #941 from dhermes/fix-90
Moving storage iterator into core modules.
2 parents 8622fa0 + d7af4f6 commit be52e91

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2014 Google Inc. All rights reserved.
1+
# Copyright 2015 Google Inc. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -22,33 +22,33 @@
2222
those results into an iterable of the actual objects you want::
2323
2424
class MyIterator(Iterator):
25-
def get_items_from_response(self, response):
26-
items = response.get('items', [])
27-
for item in items:
28-
my_item = MyItemClass(other_arg=True)
29-
my_item._set_properties(item)
30-
yield my_item
25+
def get_items_from_response(self, response):
26+
items = response.get('items', [])
27+
for item in items:
28+
my_item = MyItemClass(other_arg=True)
29+
my_item._set_properties(item)
30+
yield my_item
3131
3232
You then can use this to get **all** the results from a resource::
3333
34-
>>> iterator = MyIterator(...)
35-
>>> list(iterator) # Convert to a list (consumes all values).
34+
>>> iterator = MyIterator(...)
35+
>>> list(iterator) # Convert to a list (consumes all values).
3636
3737
Or you can walk your way through items and call off the search early if
3838
you find what you're looking for (resulting in possibly fewer
3939
requests)::
4040
41-
>>> for item in MyIterator(...):
42-
>>> print item.name
43-
>>> if not item.is_valid:
44-
>>> break
41+
>>> for item in MyIterator(...):
42+
>>> print item.name
43+
>>> if not item.is_valid:
44+
>>> break
4545
"""
4646

4747

4848
class Iterator(object):
49-
"""A generic class for iterating through Cloud Storage list responses.
49+
"""A generic class for iterating through Cloud JSON APIs list responses.
5050
51-
:type connection: :class:`gcloud.storage.connection.Connection`
51+
:type connection: :class:`gcloud.connection.Connection`
5252
:param connection: The connection to use to make requests.
5353
5454
:type path: string

gcloud/storage/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
from gcloud.exceptions import NotFound
2222
from gcloud._helpers import get_default_project
23+
from gcloud.iterator import Iterator
2324
from gcloud.storage._helpers import _require_connection
2425
from gcloud.storage.bucket import Bucket
25-
from gcloud.storage.iterator import Iterator
2626

2727

2828
def lookup_bucket(bucket_name, connection=None):

gcloud/storage/bucket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
from gcloud._helpers import get_default_project
2525
from gcloud.exceptions import NotFound
26+
from gcloud.iterator import Iterator
2627
from gcloud.storage._helpers import _PropertyMixin
2728
from gcloud.storage._helpers import _require_connection
2829
from gcloud.storage._helpers import _scalar_property
2930
from gcloud.storage.acl import BucketACL
3031
from gcloud.storage.acl import DefaultObjectACL
31-
from gcloud.storage.iterator import Iterator
3232
from gcloud.storage.blob import Blob
3333
from gcloud._helpers import _RFC3339_MICROS
3434

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2014 Google Inc. All rights reserved.
1+
# Copyright 2015 Google Inc. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
1818
class TestIterator(unittest2.TestCase):
1919

2020
def _getTargetClass(self):
21-
from gcloud.storage.iterator import Iterator
21+
from gcloud.iterator import Iterator
2222
return Iterator
2323

2424
def _makeOne(self, *args, **kw):

0 commit comments

Comments
 (0)