mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Revisit telethon_generator (closes #724)
This commit is contained in:
@@ -16,7 +16,7 @@ class SourceBuilder:
|
||||
"""
|
||||
self.write(' ' * (self.current_indent * self.indent_size))
|
||||
|
||||
def write(self, string):
|
||||
def write(self, string, *args, **kwargs):
|
||||
"""Writes a string into the source code,
|
||||
applying indentation if required
|
||||
"""
|
||||
@@ -26,13 +26,16 @@ class SourceBuilder:
|
||||
if string.strip():
|
||||
self.indent()
|
||||
|
||||
self.out_stream.write(string)
|
||||
if args or kwargs:
|
||||
self.out_stream.write(string.format(*args, **kwargs))
|
||||
else:
|
||||
self.out_stream.write(string)
|
||||
|
||||
def writeln(self, string=''):
|
||||
def writeln(self, string='', *args, **kwargs):
|
||||
"""Writes a string into the source code _and_ appends a new line,
|
||||
applying indentation if required
|
||||
"""
|
||||
self.write(string + '\n')
|
||||
self.write(string + '\n', *args, **kwargs)
|
||||
self.on_new_line = True
|
||||
|
||||
# If we're writing a block, increment indent for the next time
|
||||
|
Reference in New Issue
Block a user