Repository: googleapis/google-cloud-python

Issue:
Move gcloud.storage.iterator into gcloud's common package
We'll need this for Cloud DNS in the ManagedZones.list method (https://developers.google.com/cloud-dns/api/v1beta1/managedZones/list)



Discussion:
Also, any other API listing will require it.

Closing. We'll address this if / when it comes up, but YAGNI for now.

Relevant again due to #933.


Resolving patch:
diff --git a/gcloud/storage/iterator.py b/gcloud/iterator.py
similarity index 86%
rename from gcloud/storage/iterator.py
rename to gcloud/iterator.py
--- a/gcloud/storage/iterator.py
+++ b/gcloud/iterator.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Google Inc. All rights reserved.
+# Copyright 2015 Google Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -22,33 +22,33 @@
 those results into an iterable of the actual objects you want::
 
   class MyIterator(Iterator):
-    def get_items_from_response(self, response):
-      items = response.get('items', [])
-      for item in items:
-        my_item = MyItemClass(other_arg=True)
-        my_item._set_properties(item)
-        yield my_item
+      def get_items_from_response(self, response):
+          items = response.get('items', [])
+          for item in items:
+              my_item = MyItemClass(other_arg=True)
+              my_item._set_properties(item)
+              yield my_item
 
 You then can use this to get **all** the results from a resource::
 
-  >>> iterator = MyIterator(...)
-  >>> list(iterator)  # Convert to a list (consumes all values).
+    >>> iterator = MyIterator(...)
+    >>> list(iterator)  # Convert to a list (consumes all values).
 
 Or you can walk your way through items and call off the search early if
 you find what you're looking for (resulting in possibly fewer
 requests)::
 
-  >>> for item in MyIterator(...):
-  >>>   print item.name
-  >>>   if not item.is_valid:
-  >>>     break
+    >>> for item in MyIterator(...):
+    >>>     print item.name
+    >>>     if not item.is_valid:
+    >>>         break
 """
 
 
 class Iterator(object):
-    """A generic class for iterating through Cloud Storage list responses.
+    """A generic class for iterating through Cloud JSON APIs list responses.
 
-    :type connection: :class:`gcloud.storage.connection.Connection`
+    :type connection: :class:`gcloud.connection.Connection`
     :param connection: The connection to use to make requests.
 
     :type path: string
diff --git a/gcloud/storage/api.py b/gcloud/storage/api.py
--- a/gcloud/storage/api.py
+++ b/gcloud/storage/api.py
@@ -20,9 +20,9 @@
 
 from gcloud.exceptions import NotFound
 from gcloud._helpers import get_default_project
+from gcloud.iterator import Iterator
 from gcloud.storage._helpers import _require_connection
 from gcloud.storage.bucket import Bucket
-from gcloud.storage.iterator import Iterator
 
 
 def lookup_bucket(bucket_name, connection=None):
diff --git a/gcloud/storage/bucket.py b/gcloud/storage/bucket.py
--- a/gcloud/storage/bucket.py
+++ b/gcloud/storage/bucket.py
@@ -23,12 +23,12 @@
 
 from gcloud._helpers import get_default_project
 from gcloud.exceptions import NotFound
+from gcloud.iterator import Iterator
 from gcloud.storage._helpers import _PropertyMixin
 from gcloud.storage._helpers import _require_connection
 from gcloud.storage._helpers import _scalar_property
 from gcloud.storage.acl import BucketACL
 from gcloud.storage.acl import DefaultObjectACL
-from gcloud.storage.iterator import Iterator
 from gcloud.storage.blob import Blob
 from gcloud._helpers import _RFC3339_MICROS
 


Test patch:
diff --git a/gcloud/storage/test_iterator.py b/gcloud/test_iterator.py
similarity index 98%
rename from gcloud/storage/test_iterator.py
rename to gcloud/test_iterator.py
--- a/gcloud/storage/test_iterator.py
+++ b/gcloud/test_iterator.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Google Inc. All rights reserved.
+# Copyright 2015 Google Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 class TestIterator(unittest2.TestCase):
 
     def _getTargetClass(self):
-        from gcloud.storage.iterator import Iterator
+        from gcloud.iterator import Iterator
         return Iterator
 
     def _makeOne(self, *args, **kw):