mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Replace generated directory modules with simply files
This commit is contained in:
parent
7eab28206b
commit
e83b250a22
|
@ -114,19 +114,11 @@ class TLGenerator:
|
|||
@staticmethod
|
||||
def _write_init_py(out_dir, depth, namespace_tlobjects, type_constructors):
|
||||
# namespace_tlobjects: {'namespace', [TLObject]}
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
for ns, tlobjects in namespace_tlobjects.items():
|
||||
# Path depth to perform relative import
|
||||
current_depth = depth
|
||||
if ns:
|
||||
current_depth += 1
|
||||
init_py = os.path.join(out_dir, ns)
|
||||
else:
|
||||
init_py = out_dir
|
||||
|
||||
os.makedirs(init_py, exist_ok=True)
|
||||
init_py = os.path.join(init_py, '__init__.py')
|
||||
with open(init_py, 'w', encoding='utf-8') as file:
|
||||
with SourceBuilder(file) as builder:
|
||||
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:
|
||||
# Add the relative imports to the namespaces,
|
||||
# unless we already are in a namespace.
|
||||
if not ns:
|
||||
|
@ -141,7 +133,7 @@ class TLGenerator:
|
|||
continue
|
||||
|
||||
TLGenerator._write_source_code(
|
||||
t, builder, current_depth, type_constructors
|
||||
t, builder, depth, type_constructors
|
||||
)
|
||||
while builder.current_indent != 0:
|
||||
builder.end_block()
|
||||
|
|
Loading…
Reference in New Issue
Block a user