mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Type checking moved to utils
This commit is contained in:
parent
5823ca5613
commit
317a490cf0
@ -166,6 +166,12 @@ def async_dec():
|
|||||||
def is_string(var):
|
def is_string(var):
|
||||||
return isinstance(var, string_types)
|
return isinstance(var, string_types)
|
||||||
|
|
||||||
|
def is_dict(var):
|
||||||
|
return isinstance(var, dict)
|
||||||
|
|
||||||
|
def is_bytes(var):
|
||||||
|
return isinstance(var, bytes)
|
||||||
|
|
||||||
def is_pil_image(var):
|
def is_pil_image(var):
|
||||||
return pil_imported and isinstance(var, PIL.Image.Image)
|
return pil_imported and isinstance(var, PIL.Image.Image)
|
||||||
|
|
||||||
@ -278,6 +284,11 @@ def per_thread(key, construct_value, reset=False):
|
|||||||
|
|
||||||
return getattr(thread_local, key)
|
return getattr(thread_local, key)
|
||||||
|
|
||||||
|
def chunks(lst, n):
|
||||||
|
"""Yield successive n-sized chunks from lst."""
|
||||||
|
# https://stackoverflow.com/a/312464/9935473
|
||||||
|
for i in range(0, len(lst), n):
|
||||||
|
yield lst[i:i + n]
|
||||||
|
|
||||||
def generate_random_token():
|
def generate_random_token():
|
||||||
return ''.join(random.sample(string.ascii_letters, 16))
|
return ''.join(random.sample(string.ascii_letters, 16))
|
||||||
|
Loading…
Reference in New Issue
Block a user