Skip to content

Commit eff9021

Browse files
committed
Some informational output from the plugin, do not overwrite __init__.py
1 parent d43d5af commit eff9021

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

betterproto/plugin.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,20 @@ def generate_code(request, response):
363363
inits.add(base)
364364

365365
for base in inits:
366+
name = os.path.join(base, "__init__.py")
367+
368+
if os.path.exists(name):
369+
# Never overwrite inits as they may have custom stuff in them.
370+
continue
371+
366372
init = response.file.add()
367-
init.name = os.path.join(base, "__init__.py")
373+
init.name = name
368374
init.content = b""
369375

376+
filenames = sorted([f.name for f in response.file])
377+
for fname in filenames:
378+
print(f"Writing {fname}", file=sys.stderr)
379+
370380

371381
def main():
372382
"""The plugin's main entry point."""

0 commit comments

Comments
 (0)