aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/python/gen_includes.py
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/python/gen_includes.py
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/python/gen_includes.py')
-rw-r--r--contrib/libs/python/gen_includes.py70
1 files changed, 35 insertions, 35 deletions
diff --git a/contrib/libs/python/gen_includes.py b/contrib/libs/python/gen_includes.py
index b19b15083b6..0e024cc49d8 100644
--- a/contrib/libs/python/gen_includes.py
+++ b/contrib/libs/python/gen_includes.py
@@ -2,9 +2,9 @@ import sys
import os
import errno
from os import listdir
-from os.path import dirname, relpath, join
+from os.path import dirname, relpath, join
+
-
def ensure_dir_exists(path):
try:
os.makedirs(path)
@@ -14,25 +14,25 @@ def ensure_dir_exists(path):
else:
raise
-
+
def make_dir(directory):
if not os.path.exists(directory):
os.makedirs(directory)
-
-def files(directory):
- for dirpath, dirnames, filenames in os.walk(directory):
- for name in filenames:
- yield relpath(join(dirpath, name), directory)
-
-
+
+def files(directory):
+ for dirpath, dirnames, filenames in os.walk(directory):
+ for name in filenames:
+ yield relpath(join(dirpath, name), directory)
+
+
def headers_set(directory):
- return {
- f for f in files(directory)
- if f.endswith('.h') and not f.startswith('internal/')
- }
+ return {
+ f for f in files(directory)
+ if f.endswith('.h') and not f.startswith('internal/')
+ }
+
-
if __name__ == "__main__":
python2_path = sys.argv[1]
@@ -42,23 +42,23 @@ if __name__ == "__main__":
ensure_dir_exists(join('.', python2_path))
ensure_dir_exists(join('.', python3_path))
- only_headers2 = headers_set(python2_path)
- only_headers3 = headers_set(python3_path)
- all_headers = only_headers2 | only_headers3
-
- for header in all_headers:
- path = join(output_path, header)
- make_dir(dirname(path))
- f = open(path, 'w')
- f.write('#pragma once\n\n')
- f.write('#ifdef USE_PYTHON3\n')
- if (header in only_headers3):
- f.write('#include <' + join(python3_path, header) + '>\n')
- else:
- f.write('#error "No <' + header + '> in Python3"\n')
- f.write('#else\n')
- if (header in only_headers2):
- f.write('#include <' + join(python2_path, header) + '>\n')
- else:
- f.write('#error "No <' + header + '> in Python2"\n')
- f.write('#endif\n')
+ only_headers2 = headers_set(python2_path)
+ only_headers3 = headers_set(python3_path)
+ all_headers = only_headers2 | only_headers3
+
+ for header in all_headers:
+ path = join(output_path, header)
+ make_dir(dirname(path))
+ f = open(path, 'w')
+ f.write('#pragma once\n\n')
+ f.write('#ifdef USE_PYTHON3\n')
+ if (header in only_headers3):
+ f.write('#include <' + join(python3_path, header) + '>\n')
+ else:
+ f.write('#error "No <' + header + '> in Python3"\n')
+ f.write('#else\n')
+ if (header in only_headers2):
+ f.write('#include <' + join(python2_path, header) + '>\n')
+ else:
+ f.write('#error "No <' + header + '> in Python2"\n')
+ f.write('#endif\n')