本文整理汇总了Python中filebrowser.settings.EXTENSIONS.items方法的典型用法代码示例。如果您正苦于以下问题:Python EXTENSIONS.items方法的具体用法?Python EXTENSIONS.items怎么用?Python EXTENSIONS.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类filebrowser.settings.EXTENSIONS
的用法示例。
在下文中一共展示了EXTENSIONS.items方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_file_type
# 需要导入模块: from filebrowser.settings import EXTENSIONS [as 别名]
# 或者: from filebrowser.settings.EXTENSIONS import items [as 别名]
def _get_file_type(self):
"Get file type as defined in EXTENSIONS."
file_type = ""
for k, v in EXTENSIONS.items():
for extension in v:
if self.extension.lower() == extension.lower():
file_type = k
return file_type
示例2: get_file_extensions
# 需要导入模块: from filebrowser.settings import EXTENSIONS [as 别名]
# 或者: from filebrowser.settings.EXTENSIONS import items [as 别名]
def get_file_extensions(qs):
extensions = []
if "type" in qs and qs.get("type") in SELECT_FORMATS:
for format in SELECT_FORMATS.get(qs.get("type"), []):
extensions.extend(EXTENSIONS[format])
else:
for k, v in EXTENSIONS.items():
for item in v:
if item: extensions.append(item)
return extensions
示例3: get_file_type
# 需要导入模块: from filebrowser.settings import EXTENSIONS [as 别名]
# 或者: from filebrowser.settings.EXTENSIONS import items [as 别名]
def get_file_type(filename):
"""
Get file type as defined in EXTENSIONS.
"""
file_extension = os.path.splitext(filename)[1].lower()
file_type = ''
for k, v in EXTENSIONS.items():
for extension in v:
if file_extension == extension.lower():
file_type = k
return file_type
示例4: get_file_extensions
# 需要导入模块: from filebrowser.settings import EXTENSIONS [as 别名]
# 或者: from filebrowser.settings.EXTENSIONS import items [as 别名]
def get_file_extensions(qs):
extensions = []
if "type" in qs and qs.get("type") in SELECT_FORMATS:
for format in SELECT_FORMATS.get(qs.get("type"), []):
extensions.extend(EXTENSIONS[format])
else:
for k, v in EXTENSIONS.items():
for item in v:
if item:
extensions.append(item)
extensions = '","'.join(extensions)
extensions = '["%s"]' % extensions
return mark_safe(extensions)