mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 11:23:46 +03:00
23 lines
548 B
Python
23 lines
548 B
Python
|
from enum import Enum
|
||
|
|
||
|
|
||
|
class ConnectionMode(Enum):
|
||
|
FULL = 'full'
|
||
|
INTERMEDIATE = 'intermediate'
|
||
|
ABRIDGED = 'abridged'
|
||
|
OBFUSCATED = 'obfuscated'
|
||
|
HTTP = 'http'
|
||
|
|
||
|
|
||
|
def parse_conn_mode(mode):
|
||
|
if isinstance(mode, ConnectionMode):
|
||
|
return mode
|
||
|
elif isinstance(mode, str):
|
||
|
for cm in ConnectionMode:
|
||
|
if mode == cm.value:
|
||
|
return cm
|
||
|
|
||
|
raise ValueError(f'unknown connection mode: {mode!r}')
|
||
|
else:
|
||
|
raise TypeError(f'not a valid connection mode: {type(mode).__name__!r}')
|