Improved auto-generated source code readability

This commit is contained in:
Lonami
2016-09-05 19:12:14 +02:00
parent 251c1830a5
commit 7802fe5487
4 changed files with 44 additions and 8 deletions

View File

@@ -137,6 +137,15 @@ def generate_tlobjects(scheme_file):
builder.writeln('pass')
builder.end_block()
# Write the __repr__(self) and __str__(self) functions
builder.writeln('def __repr__(self):')
builder.writeln("return '{}'".format(repr(tlobject)))
builder.end_block()
builder.writeln('def __str__(self):')
builder.writeln("return {}".format(str(tlobject)))
# builder.end_block() # There is no need to end the last block
# Once all the objects have been generated, we can now group them in a single file
filename = os.path.join('tl', 'all_tlobjects.py')
with open(filename, 'w', encoding='utf-8') as file: