本文整理匯總了Python中filebrowser.settings.VERSIONS.keys方法的典型用法代碼示例。如果您正苦於以下問題:Python VERSIONS.keys方法的具體用法?Python VERSIONS.keys怎麽用?Python VERSIONS.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類filebrowser.settings.VERSIONS
的用法示例。
在下文中一共展示了VERSIONS.keys方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: version
# 需要導入模塊: from filebrowser.settings import VERSIONS [as 別名]
# 或者: from filebrowser.settings.VERSIONS import keys [as 別名]
def version(self):
"Returns version name"
ext = (r'_(%s)$') % ('|'.join(VERSIONS.keys()))
match = re.search(ext, self.filename_root, re.IGNORECASE)
if match:
return match.groups()[0]
return None
示例2: __init__
# 需要導入模塊: from filebrowser.settings import VERSIONS [as 別名]
# 或者: from filebrowser.settings.VERSIONS import keys [as 別名]
def __init__(self, value, version_suffix=ADMIN_THUMBNAIL):
"""
Initialize Media for filebrowser.
:param value: string with format 'app_label.model_name:pk'
:param version_suffix: string with information about version to display
"""
assert isinstance(value, str)
assert version_suffix in VERSIONS.keys()
self.value = value
try:
model_representation, self.object_id = value.split(':')
except ValueError:
raise FBExtensionObjectException(CORECT_FORMAT_EXCEPTION)
if not all((model_representation, self.object_id)):
raise FBExtensionObjectException(CORECT_FORMAT_EXCEPTION)
try:
self.app_label, self.model_name = model_representation.split('.')
except ValueError:
raise FBExtensionObjectException(CORECT_FORMAT_EXCEPTION)
self.version_suffix = version_suffix
示例3: test_should_return_correct_original_name_using_predefined_versions
# 需要導入模塊: from filebrowser.settings import VERSIONS [as 別名]
# 或者: from filebrowser.settings.VERSIONS import keys [as 別名]
def test_should_return_correct_original_name_using_predefined_versions(self):
expected = 'testimage.jpg'
for version_suffix in VERSIONS.keys():
file_object = self.F_IMAGE.version_generate(version_suffix)
namer = self._get_namer(version_suffix, file_object)
self.assertNotEqual(file_object.filename, expected)
self.assertEqual(namer.get_original_name(), expected)
self.assertEqual(file_object.original_filename, expected)
示例4: test_version_attributes_3
# 需要導入模塊: from filebrowser.settings import VERSIONS [as 別名]
# 或者: from filebrowser.settings.VERSIONS import keys [as 別名]
def test_version_attributes_3(self):
"""
FileObject version attributes/methods
with alternative versions_basedir
# is_version
# original
# original_filename
# versions_basedir
# versions
# admin_versions
# version_name(suffix)
# version_generate(suffix)
"""
# new settings
version_list = sorted(['_test/_versions/folder/testimage_{}.jpg'.format(name) for name in VERSIONS.keys()])
admin_version_list = ['_test/_versions/folder/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, "_test/_versions/")
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"), "_test/_versions/folder/testimage_large.jpg")
# version does not exist yet
f_version = FileObject(os.path.join(site.directory, 'folder', "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, "_test/_versions/folder/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)
self.assertEqual(f_version.versions(), [])
self.assertEqual(f_version.admin_versions(), [])