You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2020/01/08 06:06:56 UTC

[GitHub] [libcloud] Kami commented on a change in pull request #1397: Promote `ex_prefix` to top-level storage SDK argument

Kami commented on a change in pull request #1397: Promote `ex_prefix` to top-level storage SDK argument
URL: https://github.com/apache/libcloud/pull/1397#discussion_r364075769
 
 

 ##########
 File path: libcloud/storage/drivers/atmos.py
 ##########
 @@ -451,11 +451,35 @@ def _emc_meta(self, response):
         meta = meta.split(', ')
         return dict([x.split('=', 1) for x in meta])
 
-    def iterate_container_objects(self, container):
+    def _entries_to_objects(self, container, entries):
+        for entry in entries:
+            metadata = {'object_id': entry['id']}
+            yield Object(entry['name'], 0, '', {}, metadata, container, self)
+
+    def iterate_container_objects(self, container, prefix=None,
+                                  ex_prefix=None):
+        """
+        Return a generator of objects for the given container.
+
+        :param container: Container instance
+        :type container: :class:`Container`
+
+        :param prefix: Filter objects starting with a prefix.
+                       Filtering is performed client-side.
+        :type  prefix: ``str``
+
+        :param ex_prefix: (Deprecated.) Filter objects starting with a prefix.
+                          Filtering is performed client-side.
+        :type  ex_prefix: ``str``
+
+        :return: A generator of Object instances.
+        :rtype: ``generator`` of :class:`Object`
+        """
+        prefix = self._normalize_prefix_argument(prefix, ex_prefix)
+
         headers = {'x-emc-include-meta': '1'}
         path = self._namespace_path(container.name) + '/'
         result = self.connection.request(path, headers=headers)
         entries = self._list_objects(result.object, object_type='regular')
-        for entry in entries:
-            metadata = {'object_id': entry['id']}
-            yield Object(entry['name'], 0, '', {}, metadata, container, self)
+        objects = self._entries_to_objects(container, entries)
+        return self._filter_listed_container_objects(objects, prefix)
 
 Review comment:
   I was thinking about doing this a bit differently, but that approach also works.
   
   We just need to make sure that all the drivers which don't implement custom / server side based filtering call that method.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services