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


Python FileObject.version_name方法代码示例

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


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

示例1: FileObjectAttributeTests

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

#.........这里部分代码省略.........
        self.assertEqual(self.f_folder.is_folder, True)
        self.assertEqual(self.f_folder.is_empty, False)

    def test_version_attributes_1(self):
        """
        FileObject version attributes/methods
        without versions_basedir

        # is_version
        # original
        # versions_basedir
        # versions
        # admin_versions
        # version_name(suffix)
        # version_path(suffix)
        # version_generate(suffix)
        """
        # new settings
        filebrowser.base.VERSIONS_BASEDIR = ""
        filebrowser.base.VERSIONS = {
            'admin_thumbnail': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop'},
            'large': {'verbose_name': 'Large', 'width': 600, 'height': '', 'opts': ''},
        }
        filebrowser.base.ADMIN_VERSIONS = ['large']
        # expected test results
        version_list = ['fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg', 'fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_admin_thumbnail.jpg']
        admin_version_list = ['fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg']

        self.assertEqual(self.f_image.is_version, False)
        self.assertEqual(self.f_image.original.path, self.f_image.path)
        self.assertEqual(self.f_image.versions_basedir, "fb_test_directory/")
        self.assertEqual(self.f_image.versions(), version_list)
        self.assertEqual(self.f_image.admin_versions(), admin_version_list)
        self.assertEqual(self.f_image.version_name("large"), "testimage_large.jpg")
        self.assertEqual(self.f_image.version_path("large"), "fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg")

        # version does not exist yet
        f_version = FileObject(os.path.join(self.directory, self.tmpdir_name, "testimage_large.jpg"), site=site)
        self.assertEqual(f_version.exists, False)
        # generate version
        f_version = self.f_image.version_generate("large")
        self.assertEqual(f_version.path, "fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg")
        self.assertEqual(f_version.exists, True)
        self.assertEqual(f_version.is_version, True)
        self.assertEqual(f_version.original_filename, "testimage.jpg")
        self.assertEqual(f_version.original.path, self.f_image.path)
        # FIXME: versions should not have versions or admin_versions

    def test_version_attributes_2(self):
        """
        FileObject version attributes/methods
        with versions_basedir

        # is_version
        # original
        # versions_basedir
        # versions
        # admin_versions
        # version_name(suffix)
        # version_generate(suffix)
        """
        # new settings
        filebrowser.base.VERSIONS_BASEDIR = "fb_test_directory/_versions"
        filebrowser.base.VERSIONS = {
            'admin_thumbnail': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop'},
            'large': {'verbose_name': 'Large', 'width': 600, 'height': '', 'opts': ''},
开发者ID:23critters,项目名称:django-filebrowser,代码行数:70,代码来源:base.py


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