def directory_list(self):
        listing = []

        directories, files = STORAGE.listdir(self.location)

        def _helper(name, filetype):
            return {
                'filepath':
                os.path.join(self.path, name),
                'filetype':
                filetype,
                'filename':
                name,
                'filedate':
                STORAGE.get_modified_time(os.path.join(self.path, name)),
                'filesize':
                sizeof_fmt(STORAGE.size(os.path.join(self.path, name))),
            }

        for directoryname in directories:
            listing.append(_helper(directoryname, 'Directory'))

        for filename in files:
            listing.append(_helper(filename, 'File'))

        return listing
    def directory_list(self):
        listing = []
        directories, files = STORAGE.listdir(self.location)

        def _helper(name, filetype):
            perviewfull = ''
            perview = ''
            urlfolder = ''
            if filetype == 'Directory':
                filetype = ''
                urlfolder = '/' + name + '/'
            else:
                nm, ext = os.path.splitext(name)
                filetype = ext.replace('.', '')
                perviewfull = settings.BASE_URL + os.path.join(self.url, name)
                perview = settings.BASE_URL + os.path.join(self.url, name)

            return {
                'urlfolder':
                urlfolder,
                'isdir':
                os.path.isdir(os.path.join(self.location, name)),
                'filetype':
                filetype,
                'filename':
                name,
                'lastmodified':
                int(os.path.getmtime(os.path.join(self.location, name))),
                'perviewfull':
                perviewfull,
                'perview':
                perview,
                'size':
                STORAGE.size(os.path.join(self.path, name)),
            }

        for directoryname in directories:
            listing.append(_helper(directoryname, 'Directory'))

        for filename in files:
            listing.append(_helper(filename, 'File'))
        return listing