mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 08:14:14 +03:00
Move the auto-generated notice to only the top of the file
This commit is contained in:
parent
e83b250a22
commit
c3f679597c
|
@ -5,6 +5,8 @@ from zlib import crc32
|
|||
from collections import defaultdict
|
||||
|
||||
from .parser import SourceBuilder, TLParser
|
||||
AUTO_GEN_NOTICE = \
|
||||
'"""File generated by TLObjects\' generator. All changes will be ERASED"""'
|
||||
|
||||
|
||||
class TLGenerator:
|
||||
|
@ -75,8 +77,7 @@ class TLGenerator:
|
|||
filename = os.path.join(self._get_file('all_tlobjects.py'))
|
||||
with open(filename, 'w', encoding='utf-8') as file:
|
||||
with SourceBuilder(file) as builder:
|
||||
builder.writeln(
|
||||
'"""File generated by TLObjects\' generator. All changes will be ERASED"""')
|
||||
builder.writeln(AUTO_GEN_NOTICE)
|
||||
builder.writeln()
|
||||
|
||||
builder.writeln('from . import types, functions')
|
||||
|
@ -119,6 +120,7 @@ class TLGenerator:
|
|||
file = os.path.join(out_dir, ns + '.py' if ns else '__init__.py')
|
||||
with open(file, 'w', encoding='utf-8') as f, \
|
||||
SourceBuilder(f) as builder:
|
||||
builder.writeln(AUTO_GEN_NOTICE)
|
||||
# Add the relative imports to the namespaces,
|
||||
# unless we already are in a namespace.
|
||||
if not ns:
|
||||
|
@ -179,15 +181,6 @@ class TLGenerator:
|
|||
builder.writeln('class {}(TLObject):'.format(
|
||||
TLGenerator.get_class_name(tlobject)))
|
||||
|
||||
# Write the original .tl definition,
|
||||
# along with a "generated automatically" message
|
||||
builder.writeln(
|
||||
'"""Class generated by TLObjects\' generator. '
|
||||
'All changes will be ERASED. TL definition below.'
|
||||
)
|
||||
builder.writeln('{}"""'.format(repr(tlobject)))
|
||||
builder.writeln()
|
||||
|
||||
# Class-level variable to store its constructor ID
|
||||
builder.writeln("# Telegram's constructor (U)ID for this class")
|
||||
builder.writeln('constructor_id = {}'.format(hex(tlobject.id)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user