mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Attempt at removing cyclic dependencies
This commit is contained in:
parent
b2425eeea9
commit
e9e44795ec
|
@ -1,6 +1,5 @@
|
||||||
# This file is based on TLSharp
|
# This file is based on TLSharp
|
||||||
# https://github.com/sochix/TLSharp/blob/master/TLSharp.Core/MTProto/Crypto/AuthKey.cs
|
# https://github.com/sochix/TLSharp/blob/master/TLSharp.Core/MTProto/Crypto/AuthKey.cs
|
||||||
from errors import *
|
|
||||||
from utils import BinaryWriter, BinaryReader
|
from utils import BinaryWriter, BinaryReader
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
class TLGeneratorNotRan(Exception):
|
||||||
|
"""Occurs when you should've ran `tl_generator.py`, but you haven't"""
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(self, 'You must run `python3 tl_generator.py` first. #ReadTheDocs!')
|
||||||
|
|
||||||
|
|
||||||
class InvalidParameterError(Exception):
|
class InvalidParameterError(Exception):
|
||||||
"""Occurs when an invalid parameter is given, for example,
|
"""Occurs when an invalid parameter is given, for example,
|
||||||
when either A or B are required but none is given"""
|
when either A or B are required but none is given"""
|
||||||
|
|
10
main.py
10
main.py
|
@ -1,4 +1,10 @@
|
||||||
import tl_generator
|
import tl_generator
|
||||||
|
if not tl_generator.tlobjects_exist():
|
||||||
|
import errors
|
||||||
|
raise errors.TLGeneratorNotRan()
|
||||||
|
else:
|
||||||
|
del tl_generator
|
||||||
|
|
||||||
from tl.telegram_client import TelegramClient
|
from tl.telegram_client import TelegramClient
|
||||||
from utils.helpers import load_settings
|
from utils.helpers import load_settings
|
||||||
|
|
||||||
|
@ -6,10 +12,6 @@ from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if not tl_generator.tlobjects_exist():
|
|
||||||
print('Please run `python3 tl_generator.py` first!')
|
|
||||||
|
|
||||||
else:
|
|
||||||
print('Loading interactive example...')
|
print('Loading interactive example...')
|
||||||
|
|
||||||
# First, initialize our TelegramClient and connect
|
# First, initialize our TelegramClient and connect
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
from .source_builder import SourceBuilder
|
from .source_builder import SourceBuilder
|
||||||
from .tl_parser import TLParser, TLObject
|
from .tl_parser import TLParser
|
||||||
|
from .tlobject import TLObject
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import re
|
import re
|
||||||
from tl import TLObject
|
|
||||||
|
from parser.tlobject import TLObject
|
||||||
|
|
||||||
|
|
||||||
class TLParser:
|
class TLParser:
|
||||||
|
|
|
@ -104,8 +104,6 @@ class TLObject:
|
||||||
.format(fullname, hex(self.id), args, args_format))
|
.format(fullname, hex(self.id), args, args_format))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TLArg:
|
class TLArg:
|
||||||
def __init__(self, name, type, generic_definition):
|
def __init__(self, name, type, generic_definition):
|
||||||
"""
|
"""
|
|
@ -1,14 +1,9 @@
|
||||||
import os
|
|
||||||
# Only import most stuff if the TLObjects were generated and there were no errors
|
|
||||||
if os.path.isfile('tl/all_tlobjects.py'):
|
|
||||||
try:
|
try:
|
||||||
from .all_tlobjects import tlobjects
|
from .all_tlobjects import tlobjects
|
||||||
from .session import Session
|
from .session import Session
|
||||||
from .mtproto_request import MTProtoRequest
|
from .mtproto_request import MTProtoRequest
|
||||||
from .telegram_client import TelegramClient
|
from .telegram_client import TelegramClient
|
||||||
except Exception:
|
|
||||||
print('Please fix `tl_generator.py` and run it again')
|
except ImportError:
|
||||||
else:
|
import errors
|
||||||
print('Please run `python3 tl_generator.py` first')
|
raise errors.TLGeneratorNotRan()
|
||||||
del os
|
|
||||||
from .tlobject import TLObject, TLArg
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
# This file structure is based on TLSharp
|
# This file structure is based on TLSharp
|
||||||
# https://github.com/sochix/TLSharp/blob/master/TLSharp.Core/TelegramClient.cs
|
# https://github.com/sochix/TLSharp/blob/master/TLSharp.Core/TelegramClient.cs
|
||||||
import platform
|
import platform
|
||||||
from parser.markdown_parser import parse_message_entities
|
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
import network.authenticator
|
import network.authenticator
|
||||||
from network import MtProtoSender, TcpTransport
|
|
||||||
from errors import *
|
from errors import *
|
||||||
|
from network import MtProtoSender, TcpTransport
|
||||||
|
from parser.markdown_parser import parse_message_entities
|
||||||
|
|
||||||
from tl import Session
|
from tl import Session
|
||||||
from tl.types import PeerUser, PeerChat, PeerChannel, InputPeerUser, InputPeerChat, InputPeerChannel, InputPeerEmpty
|
from tl.types import PeerUser, PeerChat, PeerChannel, InputPeerUser, InputPeerChat, InputPeerChannel, InputPeerEmpty
|
||||||
|
|
|
@ -2,8 +2,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from parser.tl_parser import TLParser
|
from parser import SourceBuilder, TLParser
|
||||||
from parser.source_builder import SourceBuilder
|
|
||||||
|
|
||||||
|
|
||||||
def tlobjects_exist():
|
def tlobjects_exist():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user