mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-13 04:56:35 +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
|
@staticmethod
|
||||||
def _write_init_py(out_dir, depth, namespace_tlobjects, type_constructors):
|
def _write_init_py(out_dir, depth, namespace_tlobjects, type_constructors):
|
||||||
# namespace_tlobjects: {'namespace', [TLObject]}
|
# namespace_tlobjects: {'namespace', [TLObject]}
|
||||||
|
os.makedirs(out_dir, exist_ok=True)
|
||||||
for ns, tlobjects in namespace_tlobjects.items():
|
for ns, tlobjects in namespace_tlobjects.items():
|
||||||
# Path depth to perform relative import
|
file = os.path.join(out_dir, ns + '.py' if ns else '__init__.py')
|
||||||
current_depth = depth
|
with open(file, 'w', encoding='utf-8') as f, \
|
||||||
if ns:
|
SourceBuilder(f) as builder:
|
||||||
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:
|
|
||||||
# Add the relative imports to the namespaces,
|
# Add the relative imports to the namespaces,
|
||||||
# unless we already are in a namespace.
|
# unless we already are in a namespace.
|
||||||
if not ns:
|
if not ns:
|
||||||
|
@ -141,7 +133,7 @@ class TLGenerator:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
TLGenerator._write_source_code(
|
TLGenerator._write_source_code(
|
||||||
t, builder, current_depth, type_constructors
|
t, builder, depth, type_constructors
|
||||||
)
|
)
|
||||||
while builder.current_indent != 0:
|
while builder.current_indent != 0:
|
||||||
builder.end_block()
|
builder.end_block()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user