mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 05:46:29 +03:00
avoid for loop
This commit is contained in:
@@ -359,21 +359,21 @@ class Message(object):
|
|||||||
# some code for handling DC_MSG_* view types
|
# some code for handling DC_MSG_* view types
|
||||||
|
|
||||||
_view_type_mapping = {
|
_view_type_mapping = {
|
||||||
const.DC_MSG_TEXT: 'text',
|
'text': const.DC_MSG_TEXT,
|
||||||
const.DC_MSG_IMAGE: 'image',
|
'image': const.DC_MSG_IMAGE,
|
||||||
const.DC_MSG_GIF: 'gif',
|
'gif': const.DC_MSG_GIF,
|
||||||
const.DC_MSG_AUDIO: 'audio',
|
'audio': const.DC_MSG_AUDIO,
|
||||||
const.DC_MSG_VIDEO: 'video',
|
'video': const.DC_MSG_VIDEO,
|
||||||
const.DC_MSG_FILE: 'file'
|
'file': const.DC_MSG_FILE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_viewtype_code_from_name(view_type_name):
|
def get_viewtype_code_from_name(view_type_name):
|
||||||
for code, value in _view_type_mapping.items():
|
code = _view_type_mapping.get(view_type_name)
|
||||||
if value == view_type_name:
|
if code is not None:
|
||||||
return code
|
return code
|
||||||
raise ValueError("message typecode not found for {!r}, "
|
raise ValueError("message typecode not found for {!r}, "
|
||||||
"available {!r}".format(view_type_name, list(_view_type_mapping.values())))
|
"available {!r}".format(view_type_name, list(_view_type_mapping.keys())))
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user