ltdconveyor/s3/upload.py
def list_dirnames_in_directory(self, dirname):
        """List all names of directories that exist at the root of this
        bucket directory.

        Note that *directories* don't exist in S3; rather directories are
        inferred from path names.

        Parameters
        ----------
        dirname : `str`
            Directory name in the bucket relative to ``bucket_root``.

        Returns
        -------
        dirnames : `list`
            List of directory names (`str`), relative to ``bucket_root/``,
            that exist at the root of ``dirname``.
        """
        prefix = self._create_prefix(dirname)
        dirnames = []
        for obj in self._bucket.objects.filter(Prefix=prefix):
            # get directory name of every object under this path prefix
            dirname = os.path.dirname(obj.key)

            # dirname is empty if the object happens to be the directory
            # redirect object object for the prefix directory (directory
            # redirect objects are named after directories and have metadata
            # that tells Fastly to redirect the browser to the index.html
            # contained in the directory).
            if dirname == '':
                dirname = obj.key + '/'

            # Strip out the path prefix from the directory name
            rel_dirname = os.path.relpath(dirname, start=prefix)

            # If there's only one part then this directory is at the root
            # relative to the prefix. We want this.
            dir_parts = rel_dirname.split('/')
            if len(dir_parts) == 1:
                dirnames.append(dir_parts[0])

        # Above algorithm finds root directories for all *files* in sub
        # subdirectories; trim down to the unique set.
        dirnames = list(set(dirnames))

        # Remove posix-like relative directory names that can appear
        # in the bucket listing.
        for filtered_dir in ('.', '..'):
            if filtered_dir in dirnames:
                dirnames.remove(filtered_dir)

        return dirnames
def list_dirnames_in_directory(self, dirname):
        prefix = self._create_prefix(dirname)
        dirnames = []
        for obj in self._bucket.objects.filter(Prefix=prefix):
            # get directory name of every object under this path prefix
            dirname = os.path.dirname(obj.key)

            # dirname is empty if the object happens to be the directory
            # redirect object object for the prefix directory (directory
            # redirect objects are named after directories and have metadata
            # that tells Fastly to redirect the browser to the index.html
            # contained in the directory).
            if dirname == '':
                dirname = obj.key + '/'

            # Strip out the path prefix from the directory name
            rel_dirname = os.path.relpath(dirname, start=prefix)

            # If there's only one part then this directory is at the root
            # relative to the prefix. We want this.
            dir_parts = rel_dirname.split('/')
            if len(dir_parts) == 1:
                dirnames.append(dir_parts[0])

        # Above algorithm finds root directories for all *files* in sub
        # subdirectories; trim down to the unique set.
        dirnames = list(set(dirnames))

        # Remove posix-like relative directory names that can appear
        # in the bucket listing.
        for filtered_dir in ('.', '..'):
            if filtered_dir in dirnames:
                dirnames.remove(filtered_dir)

        return dirnames
def list_dirnames_in_directory ( self , dirname ) : prefix = self . _create_prefix ( dirname ) dirnames = [ ] for obj in self . _bucket . objects . filter ( Prefix = prefix ) : # get directory name of every object under this path prefix dirname = os . path . dirname ( obj . key ) # dirname is empty if the object happens to be the directory # redirect object object for the prefix directory (directory # redirect objects are named after directories and have metadata # that tells Fastly to redirect the browser to the index.html # contained in the directory). if dirname == '' : dirname = obj . key + '/' # Strip out the path prefix from the directory name rel_dirname = os . path . relpath ( dirname , start = prefix ) # If there's only one part then this directory is at the root # relative to the prefix. We want this. dir_parts = rel_dirname . split ( '/' ) if len ( dir_parts ) == 1 : dirnames . append ( dir_parts [ 0 ] ) # Above algorithm finds root directories for all *files* in sub # subdirectories; trim down to the unique set. dirnames = list ( set ( dirnames ) ) # Remove posix-like relative directory names that can appear # in the bucket listing. for filtered_dir in ( '.' , '..' ) : if filtered_dir in dirnames : dirnames . remove ( filtered_dir ) return dirnames
List all names of directories that exist at the root of this
        bucket directory.

        Note that *directories* don't exist in S3; rather directories are
        inferred from path names.

        Parameters
        ----------
        dirname : `str`
            Directory name in the bucket relative to ``bucket_root``.

        Returns
        -------
        dirnames : `list`
            List of directory names (`str`), relative to ``bucket_root/``,
            that exist at the root of ``dirname``.
List all names of directories that exist at the root of this bucket directory .