From eff9021529157a6d92f9ff6962d9f4250763ffd5 Mon Sep 17 00:00:00 2001 From: "Daniel G. Taylor" Date: Wed, 23 Oct 2019 15:07:05 -0700 Subject: [PATCH] Some informational output from the plugin, do not overwrite __init__.py --- betterproto/plugin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/betterproto/plugin.py b/betterproto/plugin.py index cec96a9..a227947 100755 --- a/betterproto/plugin.py +++ b/betterproto/plugin.py @@ -363,10 +363,20 @@ def generate_code(request, response): inits.add(base) for base in inits: + name = os.path.join(base, "__init__.py") + + if os.path.exists(name): + # Never overwrite inits as they may have custom stuff in them. + continue + init = response.file.add() - init.name = os.path.join(base, "__init__.py") + init.name = name init.content = b"" + filenames = sorted([f.name for f in response.file]) + for fname in filenames: + print(f"Writing {fname}", file=sys.stderr) + def main(): """The plugin's main entry point."""