当前位置: 首页>>代码示例>>Python>>正文


Python FileListing.files_walk_total方法代码示例

本文整理汇总了Python中filebrowser.base.FileListing.files_walk_total方法的典型用法代码示例。如果您正苦于以下问题:Python FileListing.files_walk_total方法的具体用法?Python FileListing.files_walk_total怎么用?Python FileListing.files_walk_total使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在filebrowser.base.FileListing的用法示例。


在下文中一共展示了FileListing.files_walk_total方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete_confirm

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import files_walk_total [as 别名]
 def delete_confirm(self, request):
     """
     Delete existing File/Directory.
     """
     query = request.GET
     path = u'%s' % os.path.join(self.directory, query.get('dir', ''))
     fileobject = FileObject(os.path.join(path, query.get('filename', '')), site=self)
     if fileobject.filetype == "Folder":
         filelisting = FileListing(os.path.join(path, fileobject.filename),
             sorting_by=query.get('o', 'filename'),
             sorting_order=query.get('ot', DEFAULT_SORTING_ORDER),
             site=self)
         filelisting = filelisting.files_walk_total()
         if len(filelisting) > 100:
             additional_files = len(filelisting) - 100
             filelisting = filelisting[:100]
         else:
             additional_files = None
     else:
         filelisting = None
         additional_files = None
     
     return render_to_response('filebrowser/delete_confirm.html', {
         'fileobject': fileobject,
         'filelisting': filelisting,
         'additional_files': additional_files,
         'query': query,
         'title': _(u'Confirm delete'),
         'is_popup': "pop" in request.REQUEST,
         'settings_var': get_settings_var(directory=self.directory),
         'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')),
         'breadcrumbs_title': _(u'Confirm delete'),
         'filebrowser_site': self
     }, context_instance=Context(request, current_app=self.name))
开发者ID:bsavelev,项目名称:django-filebrowser-no-grappelli-django14,代码行数:36,代码来源:sites.py

示例2: delete_confirm

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import files_walk_total [as 别名]
def delete_confirm(request):
    """
    Delete existing File/Directory.
    """
    query = request.GET
    abs_path = u'%s' % os.path.join(MEDIA_ROOT, DIRECTORY, query.get('dir', ''))
    fileobject = FileObject(os.path.join(abs_path, query.get('filename', '')))
    if fileobject.filetype == "Folder":
        filelisting = FileListing(os.path.join(abs_path, fileobject.filename),
            filter_func=filter_browse,
            sorting_by=query.get('o', 'filename'),
            sorting_order=query.get('ot', DEFAULT_SORTING_ORDER))
        filelisting = filelisting.files_walk_total()
        if len(filelisting) > 100:
            additional_files = len(filelisting) - 100
            filelisting = filelisting[:100]
        else:
            additional_files = None
    else:
        filelisting = None
        additional_files = None
    
    return render_to_response('filebrowser/delete_confirm.html', {
        'fileobject': fileobject,
        'filelisting': filelisting,
        'additional_files': additional_files,
        'query': query,
        'title': _(u'Confirm delete'),
        'settings_var': get_settings_var(),
        'breadcrumbs': get_breadcrumbs(query, query.get('dir', '')),
        'breadcrumbs_title': _(u'Confirm delete')
    }, context_instance=Context(request))
开发者ID:dblundell,项目名称:django-filebrowser,代码行数:34,代码来源:views.py

示例3: gallery_detail

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import files_walk_total [as 别名]
def gallery_detail(request, category_slug, slug):
    gallery = get_object_or_404(Gallery, slug=slug)
    filelisting = FileListing(gallery.folder.path)
    photos = filelisting.files_walk_total()
    return render_to_response('gallery/gallery_detail.html',
                              {'gallery': gallery,
                               'photos': photos})
开发者ID:soner,项目名称:lubnik,代码行数:9,代码来源:views.py

示例4: delete_confirm

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import files_walk_total [as 别名]
    def delete_confirm(self, request):
        """
        Delete existing File/Directory.
        """
        query = request.GET
        abs_path = u"%s" % os.path.join(self.media_root, query.get("dir", ""))
        fileobject = FileObject(
            os.path.join(abs_path, query.get("filename", "")), media_root=self.media_root, media_url=self.media_url
        )
        if fileobject.filetype == "Folder":
            filelisting = FileListing(
                os.path.join(abs_path, fileobject.filename),
                sorting_by=query.get("o", "filename"),
                sorting_order=query.get("ot", DEFAULT_SORTING_ORDER),
                media_root=self.media_root,
                media_url=self.media_url,
            )
            filelisting = filelisting.files_walk_total()
            if len(filelisting) > 100:
                additional_files = len(filelisting) - 100
                filelisting = filelisting[:100]
            else:
                additional_files = None
        else:
            filelisting = None
            additional_files = None

        return render_to_response(
            "filebrowser/delete_confirm.html",
            {
                "fileobject": fileobject,
                "filelisting": filelisting,
                "additional_files": additional_files,
                "query": query,
                "title": _(u"Confirm delete"),
                "settings_var": get_settings_var(media_root=self.media_root, media_url=self.media_url),
                "breadcrumbs": get_breadcrumbs(query, query.get("dir", "")),
                "breadcrumbs_title": _(u"Confirm delete"),
                "media_root": self.media_root,
                "media_url": self.media_url,
            },
            context_instance=Context(request, current_app=self.name),
        )
开发者ID:avanheuvelen,项目名称:django-filebrowser,代码行数:45,代码来源:sites.py

示例5: FileListingTests

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import files_walk_total [as 别名]
class FileListingTests(TestCase):
    """
    /_test/uploads/testimage.jpg
    /_test/uploads/folder/
    /_test/uploads/folder/subfolder/
    /_test/uploads/folder/subfolder/testimage.jpg
    """

    def setUp(self):
        super(FileListingTests, self).setUp()

        self.F_LISTING_FOLDER = FileListing(self.DIRECTORY, sorting_by='date', sorting_order='desc')
        self.F_LISTING_IMAGE = FileListing(os.path.join(self.DIRECTORY, 'folder', 'subfolder', "testimage.jpg"))

        shutil.copy(self.STATIC_IMG_PATH, self.SUBFOLDER_PATH)
        shutil.copy(self.STATIC_IMG_PATH, self.DIRECTORY_PATH)

    def test_init_attributes(self):

        """
        FileListing init attributes

        # path
        # filter_func
        # sorting_by
        # sorting_order
        """
        self.assertEqual(self.F_LISTING_FOLDER.path, '_test/uploads/')
        self.assertEqual(self.F_LISTING_FOLDER.filter_func, None)
        self.assertEqual(self.F_LISTING_FOLDER.sorting_by, 'date')
        self.assertEqual(self.F_LISTING_FOLDER.sorting_order, 'desc')

    def test_listing(self):
        """
        FileObject listing

        # listing
        # files_listing_total
        # files_listing_filtered
        # results_listing_total
        # results_listing_filtered
        """

        self.assertEqual(self.F_LISTING_IMAGE.listing(), [])
        self.assertEqual(list(self.F_LISTING_FOLDER.listing()), [u'folder', u'testimage.jpg'])
        self.assertEqual(list(f.path for f in self.F_LISTING_FOLDER.files_listing_total()), [u'_test/uploads/testimage.jpg', u'_test/uploads/folder'])
        self.assertEqual(list(f.path for f in self.F_LISTING_FOLDER.files_listing_filtered()), [u'_test/uploads/testimage.jpg', u'_test/uploads/folder'])
        self.assertEqual(self.F_LISTING_FOLDER.results_listing_total(), 2)
        self.assertEqual(self.F_LISTING_FOLDER.results_listing_filtered(), 2)

    def test_listing_filtered(self):
        """
        FileObject listing

        # listing
        # files_listing_total
        # files_listing_filtered
        # results_listing_total
        # results_listing_filtered
        """

        self.assertEqual(self.F_LISTING_IMAGE.listing(), [])
        self.assertEqual(list(self.F_LISTING_FOLDER.listing()), [u'folder', u'testimage.jpg'])
        self.assertEqual(list(f.path for f in self.F_LISTING_FOLDER.files_listing_total()), [u'_test/uploads/testimage.jpg', u'_test/uploads/folder'])
        self.assertEqual(list(f.path for f in self.F_LISTING_FOLDER.files_listing_filtered()), [u'_test/uploads/testimage.jpg', u'_test/uploads/folder'])
        self.assertEqual(self.F_LISTING_FOLDER.results_listing_total(), 2)
        self.assertEqual(self.F_LISTING_FOLDER.results_listing_filtered(), 2)

    def test_walk(self):
        """
        FileObject walk

        # walk
        # files_walk_total
        # files_walk_filtered
        # results_walk_total
        # results_walk_filtered
        """

        self.assertEqual(self.F_LISTING_IMAGE.walk(), [])
        self.assertEqual(list(self.F_LISTING_FOLDER.walk()), [u'folder/subfolder/testimage.jpg', u'folder/subfolder', u'folder', u'testimage.jpg'])
        self.assertEqual(list(f.path for f in self.F_LISTING_FOLDER.files_walk_total()), [u'_test/uploads/testimage.jpg', u'_test/uploads/folder', u'_test/uploads/folder/subfolder', u'_test/uploads/folder/subfolder/testimage.jpg'])
        self.assertEqual(list(f.path for f in self.F_LISTING_FOLDER.files_walk_filtered()), [u'_test/uploads/testimage.jpg', u'_test/uploads/folder', u'_test/uploads/folder/subfolder', u'_test/uploads/folder/subfolder/testimage.jpg'])
        self.assertEqual(self.F_LISTING_FOLDER.results_walk_total(), 4)
        self.assertEqual(self.F_LISTING_FOLDER.results_walk_filtered(), 4)
开发者ID:CarlosOV,项目名称:django-filebrowser,代码行数:87,代码来源:test_base.py

示例6: FileListingTests

# 需要导入模块: from filebrowser.base import FileListing [as 别名]
# 或者: from filebrowser.base.FileListing import files_walk_total [as 别名]

#.........这里部分代码省略.........
        # create temporary test folder and move testimage
        # FIXME: find better path names
        self.tmpdir_name = os.path.join("fb_tmp_dir", "fb_tmp_dir_sub")
        self.tmpdir_path = os.path.join(site.storage.location, self.directory, self.tmpdir_name)
        if os.path.exists(self.tmpdir_path):
            self.fail("Temporary testfolder already exists.")
        else:
            os.makedirs(self.tmpdir_path)

        # copy test image to temporary test folder
        self.image_path = os.path.join(FILEBROWSER_PATH, "static", "filebrowser", "img", "testimage.jpg")
        if not os.path.exists(self.image_path):
            self.fail("Testimage not found.")
        shutil.copy(self.image_path, self.directory_path)
        shutil.copy(self.image_path, self.tmpdir_path)

        # set posixpath
        filebrowser.base.os.path = posixpath

        # filelisting/fileobject
        self.f_listing = FileListing(self.directory, sorting_by='date', sorting_order='desc')
        self.f_listing_file = FileListing(os.path.join(self.directory, self.tmpdir_name, "testimage.jpg"))

    def test_init_attributes(self):
        """
        FileListing init attributes

        # path
        # filter_func
        # sorting_by
        # sorting_order
        """
        self.assertEqual(self.f_listing.path, 'fb_test_directory/')
        self.assertEqual(self.f_listing.filter_func, None)
        self.assertEqual(self.f_listing.sorting_by, 'date')
        self.assertEqual(self.f_listing.sorting_order, 'desc')

    def test_listing(self):
        """
        FileObject listing

        # listing
        # files_listing_total
        # files_listing_filtered
        # results_listing_total
        # results_listing_filtered
        """
        self.assertEqual(self.f_listing_file.listing(), [])
        self.assertEqual(list(self.f_listing.listing()), [u'fb_tmp_dir', u'testimage.jpg'])
        self.assertEqual(list(f.path for f in self.f_listing.files_listing_total()), [u'fb_test_directory/testimage.jpg', u'fb_test_directory/fb_tmp_dir'])
        self.assertEqual(list(f.path for f in self.f_listing.files_listing_filtered()), [u'fb_test_directory/testimage.jpg', u'fb_test_directory/fb_tmp_dir'])
        self.assertEqual(self.f_listing.results_listing_total(), 2)
        self.assertEqual(self.f_listing.results_listing_filtered(), 2)

    def test_listing_filtered(self):
        """
        FileObject listing

        # listing
        # files_listing_total
        # files_listing_filtered
        # results_listing_total
        # results_listing_filtered
        """
        self.assertEqual(self.f_listing_file.listing(), [])
        self.assertEqual(list(self.f_listing.listing()), [u'fb_tmp_dir', u'testimage.jpg'])
        self.assertEqual(list(f.path for f in self.f_listing.files_listing_total()), [u'fb_test_directory/testimage.jpg', u'fb_test_directory/fb_tmp_dir'])
        self.assertEqual(list(f.path for f in self.f_listing.files_listing_filtered()), [u'fb_test_directory/testimage.jpg', u'fb_test_directory/fb_tmp_dir'])
        self.assertEqual(self.f_listing.results_listing_total(), 2)
        self.assertEqual(self.f_listing.results_listing_filtered(), 2)

    def test_walk(self):
        """
        FileObject walk

        # walk
        # files_walk_total
        # files_walk_filtered
        # results_walk_total
        # results_walk_filtered
        """
        self.assertEqual(self.f_listing_file.walk(), [])
        self.assertEqual(list(self.f_listing.walk()), [u'fb_tmp_dir/fb_tmp_dir_sub/testimage.jpg', u'fb_tmp_dir/fb_tmp_dir_sub', u'fb_tmp_dir', u'testimage.jpg'])
        self.assertEqual(list(f.path for f in self.f_listing.files_walk_total()),  [u'fb_test_directory/testimage.jpg', u'fb_test_directory/fb_tmp_dir', u'fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub', u'fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage.jpg'])
        self.assertEqual(list(f.path for f in self.f_listing.files_walk_filtered()),  [u'fb_test_directory/testimage.jpg', u'fb_test_directory/fb_tmp_dir', u'fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub', u'fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage.jpg'])
        self.assertEqual(self.f_listing.results_walk_total(), 4)
        self.assertEqual(self.f_listing.results_walk_filtered(), 4)

    def tearDown(self):
        """
        Restore original values/functions
        """
        filebrowser.base.os.path = self.original_path
        site.directory = self.original_directory
        filebrowser.base.VERSIONS_BASEDIR = self.original_versions_basedir
        filebrowser.base.VERSIONS = self.original_versions
        filebrowser.base.ADMIN_VERSIONS = self.original_admin_versions

        # remove temporary directory and test folder
        shutil.rmtree(self.directory_path)
开发者ID:23critters,项目名称:django-filebrowser,代码行数:104,代码来源:base.py


注:本文中的filebrowser.base.FileListing.files_walk_total方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。