mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Refactor some redundant elifs
This commit is contained in:
parent
277eb8b701
commit
be622ca559
4 changed files with 43 additions and 43 deletions
|
|
@ -120,15 +120,15 @@ class HelperMode(Helper):
|
|||
"""
|
||||
if mode == cls.SCREAMING_SNAKE_CASE:
|
||||
return cls._screaming_snake_case(text)
|
||||
elif mode == cls.snake_case:
|
||||
if mode == cls.snake_case:
|
||||
return cls._snake_case(text)
|
||||
elif mode == cls.lowercase:
|
||||
if mode == cls.lowercase:
|
||||
return cls._snake_case(text).replace('_', '')
|
||||
elif mode == cls.lowerCamelCase:
|
||||
if mode == cls.lowerCamelCase:
|
||||
return cls._camel_case(text)
|
||||
elif mode == cls.CamelCase:
|
||||
if mode == cls.CamelCase:
|
||||
return cls._camel_case(text, True)
|
||||
elif callable(mode):
|
||||
if callable(mode):
|
||||
return mode(text)
|
||||
return text
|
||||
|
||||
|
|
|
|||
|
|
@ -52,14 +52,14 @@ def prepare_arg(value):
|
|||
"""
|
||||
if value is None:
|
||||
return value
|
||||
elif isinstance(value, (list, dict)) or hasattr(value, 'to_python'):
|
||||
if isinstance(value, (list, dict)) or hasattr(value, 'to_python'):
|
||||
return json.dumps(_normalize(value))
|
||||
elif isinstance(value, datetime.timedelta):
|
||||
if isinstance(value, datetime.timedelta):
|
||||
now = datetime.datetime.now()
|
||||
return int((now + value).timestamp())
|
||||
elif isinstance(value, datetime.datetime):
|
||||
if isinstance(value, datetime.datetime):
|
||||
return round(value.timestamp())
|
||||
elif isinstance(value, LazyProxy):
|
||||
if isinstance(value, LazyProxy):
|
||||
return str(value)
|
||||
return value
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue