aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/gen_py_protos.py
diff options
context:
space:
mode:
authordeshevoy <deshevoy@yandex-team.ru>2022-02-10 16:46:57 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:57 +0300
commit28148f76dbfcc644d96427d41c92f36cbf2fdc6e (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /build/scripts/gen_py_protos.py
parente988f30484abe5fdeedcc7a5d3c226c01a21800c (diff)
downloadydb-28148f76dbfcc644d96427d41c92f36cbf2fdc6e.tar.gz
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/gen_py_protos.py')
-rw-r--r--build/scripts/gen_py_protos.py56
1 files changed, 28 insertions, 28 deletions
diff --git a/build/scripts/gen_py_protos.py b/build/scripts/gen_py_protos.py
index a5355bc03e..08397472f9 100644
--- a/build/scripts/gen_py_protos.py
+++ b/build/scripts/gen_py_protos.py
@@ -4,42 +4,42 @@ import shutil
import subprocess
import sys
import tempfile
-import argparse
-import re
+import argparse
+import re
OUT_DIR_ARG = '--python_out='
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("--suffixes", nargs="*", default=[])
- parser.add_argument("protoc_args", nargs=argparse.REMAINDER)
- script_args = parser.parse_args()
-
- args = script_args.protoc_args
-
- if args[0] == "--":
- args = args[1:]
-
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--suffixes", nargs="*", default=[])
+ parser.add_argument("protoc_args", nargs=argparse.REMAINDER)
+ script_args = parser.parse_args()
+
+ args = script_args.protoc_args
+
+ if args[0] == "--":
+ args = args[1:]
+
out_dir_orig = None
out_dir_temp = None
- plugin_out_dirs_orig = {}
+ plugin_out_dirs_orig = {}
for i in range(len(args)):
if args[i].startswith(OUT_DIR_ARG):
assert not out_dir_orig, 'Duplicate "{0}" param'.format(OUT_DIR_ARG)
out_dir_orig = args[i][len(OUT_DIR_ARG):]
out_dir_temp = tempfile.mkdtemp(dir=out_dir_orig)
args[i] = OUT_DIR_ARG + out_dir_temp
- continue
-
- match = re.match(r"^(--(\w+)_out=).*", args[i])
- if match:
- plugin_out_dir_arg = match.group(1)
- plugin = match.group(2)
- assert plugin not in plugin_out_dirs_orig, 'Duplicate "{0}" param'.format(plugin_out_dir_arg)
- plugin_out_dirs_orig[plugin] = args[i][len(plugin_out_dir_arg):]
- assert plugin_out_dirs_orig[plugin] == out_dir_orig, 'Params "{0}" and "{1}" expected to have the same value'.format(OUT_DIR_ARG, plugin_out_dir_arg)
- args[i] = plugin_out_dir_arg + out_dir_temp
+ continue
+
+ match = re.match(r"^(--(\w+)_out=).*", args[i])
+ if match:
+ plugin_out_dir_arg = match.group(1)
+ plugin = match.group(2)
+ assert plugin not in plugin_out_dirs_orig, 'Duplicate "{0}" param'.format(plugin_out_dir_arg)
+ plugin_out_dirs_orig[plugin] = args[i][len(plugin_out_dir_arg):]
+ assert plugin_out_dirs_orig[plugin] == out_dir_orig, 'Params "{0}" and "{1}" expected to have the same value'.format(OUT_DIR_ARG, plugin_out_dir_arg)
+ args[i] = plugin_out_dir_arg + out_dir_temp
assert out_dir_temp, 'Param "{0}" not found'.format(OUT_DIR_ARG)
@@ -55,13 +55,13 @@ def main():
os.mkdir(d_orig)
for f in files:
f_orig = f
- for suf in script_args.suffixes:
- if f.endswith(suf):
- f_orig = f[:-len(suf)] + "__int__" + suf
+ for suf in script_args.suffixes:
+ if f.endswith(suf):
+ f_orig = f[:-len(suf)] + "__int__" + suf
break
os.rename(path.join(root_temp, f), path.join(root_orig, f_orig))
shutil.rmtree(out_dir_temp)
if __name__ == '__main__':
- main()
+ main()