示例#1
0
def gen_tl():
    from telethon_generator.tl_generator import TLGenerator
    generator = TLGenerator('telethon/tl')
    if generator.tlobjects_exist():
        print('Detected previous TLObjects. Cleaning...')
        generator.clean_tlobjects()

    print('Generating TLObjects...')
    generator.generate_tlobjects('telethon_generator/scheme.tl',
                                 import_depth=2)
    print('Done.')
示例#2
0
def gen_tl():
    from telethon_generator.tl_generator import TLGenerator
    from telethon_generator.error_generator import generate_code
    generator = TLGenerator(GENERATOR_DIR)
    if generator.tlobjects_exist():
        print('Detected previous TLObjects. Cleaning...')
        generator.clean_tlobjects()

    print('Generating TLObjects...')
    generator.generate_tlobjects(SCHEME_TL, import_depth=IMPORT_DEPTH)
    print('Generating errors...')
    generate_code(ERROR_LIST, json_file=ERRORS_JSON, errors_desc=ERRORS_DESC)
    print('Done.')
示例#3
0
def main():
    if len(argv) >= 2 and argv[1] == 'gen_tl':
        gen_tl()

    elif len(argv) >= 2 and argv[1] == 'clean_tl':
        from telethon_generator.tl_generator import TLGenerator
        print('Cleaning...')
        TLGenerator(GENERATOR_DIR).clean_tlobjects()
        print('Done.')

    elif len(argv) >= 2 and argv[1] == 'pypi':
        # (Re)generate the code to make sure we don't push without it
        gen_tl()

        # Try importing the telethon module to assert it has no errors
        try:
            import telethon
        except:
            print('Packaging for PyPi aborted, importing the module failed.')
            return

        # Need python3.5 or higher, but Telethon is supposed to support 3.x
        # Place it here since noone should be running ./setup.py pypi anyway
        from subprocess import run
        from shutil import rmtree

        for x in ('build', 'dist', 'Telethon.egg-info'):
            rmtree(x, ignore_errors=True)
        run('python3 setup.py sdist', shell=True)
        run('python3 setup.py bdist_wheel', shell=True)
        run('twine upload dist/*', shell=True)
        for x in ('build', 'dist', 'Telethon.egg-info'):
            rmtree(x, ignore_errors=True)

    elif len(argv) >= 2 and argv[1] == 'fetch_errors':
        from telethon_generator.error_generator import fetch_errors
        fetch_errors(ERRORS_JSON)

    else:
        # Call gen_tl() if the scheme.tl file exists, e.g. install from GitHub
        if os.path.isfile(SCHEME_TL):
            gen_tl(force=False)

        # Get the long description from the README file
        with open('README.rst', encoding='utf-8') as f:
            long_description = f.read()

        with open('telethon/version.py', encoding='utf-8') as f:
            version = re.search(r"^__version__\s*=\s*'(.*)'.*$",
                                f.read(),
                                flags=re.MULTILINE).group(1)
        setup(
            name='Telethon',
            version=version,
            description="Full-featured Telegram client library for Python 3",
            long_description=long_description,
            url='https://github.com/LonamiWebs/Telethon',
            download_url='https://github.com/LonamiWebs/Telethon/releases',
            author='Lonami Exo',
            author_email='*****@*****.**',
            license='MIT',

            # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
            classifiers=[
                #   3 - Alpha
                #   4 - Beta
                #   5 - Production/Stable
                'Development Status :: 3 - Alpha',
                'Intended Audience :: Developers',
                'Topic :: Communications :: Chat',
                'License :: OSI Approved :: MIT License',
                'Programming Language :: Python :: 3',
                'Programming Language :: Python :: 3.3',
                'Programming Language :: Python :: 3.4',
                'Programming Language :: Python :: 3.5',
                'Programming Language :: Python :: 3.6'
            ],
            keywords='telegram api chat client library messaging mtproto',
            packages=find_packages(exclude=[
                'telethon_generator', 'telethon_tests', 'run_tests.py',
                'try_telethon.py'
            ]),
            install_requires=['pyaes', 'rsa'],
            extras_require={'cryptg': ['cryptg']})
示例#4
0
from codecs import open
from sys import argv
from os import path

# Always prefer setuptools over distutils
from setuptools import find_packages, setup

try:
    from telethon import TelegramClient
except ImportError:
    TelegramClient = None

if __name__ == '__main__':
    if len(argv) >= 2 and argv[1] == 'gen_tl':
        from telethon_generator.tl_generator import TLGenerator
        generator = TLGenerator('telethon/tl')
        if generator.tlobjects_exist():
            print('Detected previous TLObjects. Cleaning...')
            generator.clean_tlobjects()

        print('Generating TLObjects...')
        generator.generate_tlobjects('telethon_generator/scheme.tl',
                                     import_depth=2)
        print('Done.')

    elif len(argv) >= 2 and argv[1] == 'clean_tl':
        from telethon_generator.tl_generator import TLGenerator
        print('Cleaning...')
        TLGenerator('telethon/tl').clean_tlobjects()
        print('Done.')
示例#5
0
文件: setup.py 项目: Chegeek/BitBot
from sys import argv
from os import path

# Always prefer setuptools over distutils
from setuptools import find_packages, setup

try:
    from telethon import TelegramClient
except ImportError:
    TelegramClient = None


if __name__ == '__main__':
    if len(argv) >= 2 and argv[1] == 'gen_tl':
        from telethon_generator.tl_generator import TLGenerator
        generator = TLGenerator('telethon/tl')
        if generator.tlobjects_exist():
            print('Detected previous TLObjects. Cleaning...')
            generator.clean_tlobjects()

        print('Generating TLObjects...')
        generator.generate_tlobjects(
            'telethon_generator/scheme.tl', import_depth=2
        )
        print('Done.')

    elif len(argv) >= 2 and argv[1] == 'clean_tl':
        from telethon_generator.tl_generator import TLGenerator
        print('Cleaning...')
        TLGenerator('telethon/tl').clean_tlobjects()
        print('Done.')
示例#6
0
def main():
    if len(argv) >= 2 and argv[1] == 'gen_tl':
        gen_tl()

    elif len(argv) >= 2 and argv[1] == 'clean_tl':
        from telethon_generator.tl_generator import TLGenerator
        print('Cleaning...')
        TLGenerator('telethon/tl').clean_tlobjects()
        print('Done.')

    elif len(argv) >= 2 and argv[1] == 'pypi':
        # Need python3.5 or higher, but Telethon is supposed to support 3.x
        # Place it here since noone should be running ./setup.py pypi anyway
        from subprocess import run
        from shutil import rmtree

        for x in ('build', 'dist', 'Telethon.egg-info'):
            rmtree(x, ignore_errors=True)
        run('python3 setup.py sdist', shell=True)
        run('python3 setup.py bdist_wheel', shell=True)
        run('twine upload dist/*', shell=True)
        for x in ('build', 'dist', 'Telethon.egg-info'):
            rmtree(x, ignore_errors=True)

    else:
        if not TelegramClient:
            gen_tl()
            from telethon import TelegramClient as TgClient
            version = TgClient.__version__
        else:
            version = TelegramClient.__version__

        # Get the long description from the README file
        with open('README.rst', encoding='utf-8') as f:
            long_description = f.read()

        setup(
            name='Telethon',

            # Versions should comply with PEP440.
            version=version,
            description="Full-featured Telegram client library for Python 3",
            long_description=long_description,
            url='https://github.com/LonamiWebs/Telethon',
            download_url='https://github.com/LonamiWebs/Telethon/releases',
            author='Lonami Exo',
            author_email='*****@*****.**',
            license='MIT',

            # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
            classifiers=[
                #   3 - Alpha
                #   4 - Beta
                #   5 - Production/Stable
                'Development Status :: 3 - Alpha',
                'Intended Audience :: Developers',
                'Topic :: Communications :: Chat',
                'License :: OSI Approved :: MIT License',
                'Programming Language :: Python :: 3',
                'Programming Language :: Python :: 3.3',
                'Programming Language :: Python :: 3.4',
                'Programming Language :: Python :: 3.5',
                'Programming Language :: Python :: 3.6'
            ],
            keywords='telegram api chat client library messaging mtproto',
            packages=find_packages(exclude=[
                'telethon_generator', 'telethon_tests', 'run_tests.py',
                'try_telethon.py'
            ]),
            install_requires=['pyaes', 'rsa'])