Exemple #1
0
    def get_container_listing(self,
                              container,
                              path,
                              marker=None,
                              all_files=None):
        if all_files is None:
            all_files = OrderedDict()
        prefix = None
        if path:
            prefix = "%s/" % path
        d = self.swiftconn.get_container(container,
                                         prefix=prefix,
                                         delimiter='/',
                                         marker=marker)

        def cb(results):
            _, files = results
            next_marker = None
            for f in files:
                if 'subdir' in f:
                    f['name'] = f['subdir']
                    f['content-type'] = 'application/directory'
                f['formatted_name'] = os.path.basename(
                    f['name'].encode("utf-8").rstrip('/'))
                all_files[f['formatted_name']] = f
                next_marker = f['name']
            if len(files) > 0:
                return self.get_container_listing(container,
                                                  path,
                                                  marker=next_marker,
                                                  all_files=all_files)
            return all_files

        d.addCallback(cb)
        return d
Exemple #2
0
 def __init__(self, swiftfilesystem, fullpath):
     self.swiftfilesystem = swiftfilesystem
     self.fullpath = fullpath
     # A lot of clients require . and .. to be within the directory listing
     self.files = OrderedDict([
         ('.', {}),
         ('..', {}),
     ])
Exemple #3
0
    def get_account_listing(self, marker=None, all_files=None):
        if all_files is None:
            all_files = OrderedDict()
        d = self.swiftconn.get_account(marker=marker)

        def cb(results):
            _, files = results
            next_marker = None
            for f in files:
                f['content-type'] = 'application/directory'
                f['formatted_name'] = f['name'].encode("utf-8")
                all_files[f['formatted_name']] = f
                next_marker = f['name']
            if len(files) > 0:
                return self.get_account_listing(marker=next_marker,
                                                all_files=all_files)
            return all_files

        d.addCallback(cb)
        return d