aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsvidyuk <svidyuk@yandex-team.com>2022-12-19 05:54:18 +0300
committersvidyuk <svidyuk@yandex-team.com>2022-12-19 05:54:18 +0300
commit2c1ec10754b67a23ca1d6309971683a5d5802d16 (patch)
treeffccafb541273cb2a76223d1d51e6d715db9d2df
parentaf4657d63ebcae43d03c05ef1def1ede532f4570 (diff)
downloadydb-2c1ec10754b67a23ca1d6309971683a5d5802d16.tar.gz
Use py3 for vcs_info.py
-rw-r--r--build/scripts/vcs_info.py37
1 files changed, 11 insertions, 26 deletions
diff --git a/build/scripts/vcs_info.py b/build/scripts/vcs_info.py
index a91aa9792c..8b4de2cd0c 100644
--- a/build/scripts/vcs_info.py
+++ b/build/scripts/vcs_info.py
@@ -12,17 +12,11 @@ import zipfile
class _Formatting(object):
@staticmethod
def is_str(strval):
- if sys.version_info >= (3, 0, 0):
- return isinstance(strval, (bytes, str))
- else:
- return isinstance(strval, basestring)
+ return isinstance(strval, (bytes, str))
@staticmethod
def encoding_needed(strval):
- if sys.version_info >= (3, 0, 0):
- return isinstance(strval, str)
- else:
- return isinstance(strval, unicode)
+ return isinstance(strval, str)
@staticmethod
def escape_special_symbols(strval):
@@ -30,8 +24,7 @@ class _Formatting(object):
c_str = strval.encode('utf-8') if encoding_needed else strval
retval = b""
for c in c_str:
- if sys.version_info >= (3, 0, 0):
- c = bytes([c])
+ c = bytes([c])
if c in ("\\", "\""):
retval += "\\" + c
elif ord(c) < ord(' '):
@@ -93,12 +86,12 @@ def get_json(file_name):
out = json.load(f)
# TODO: check 'tar+svn' parsing
- for i in ['ARCADIA_SOURCE_REVISION', 'ARCADIA_SOURCE_LAST_CHANGE', 'SVN_REVISION']:
- if i in out and _Formatting.is_str(out[i]):
+ for num_var in ['ARCADIA_SOURCE_REVISION', 'ARCADIA_SOURCE_LAST_CHANGE', 'SVN_REVISION']:
+ if num_var in out and _Formatting.is_str(out[num_var]):
try:
- out[i] = int(out[i])
+ out[num_var] = int(out[num_var])
except:
- out[i] = -1
+ out[num_var] = -1
return out
except:
return get_default_json()
@@ -109,20 +102,12 @@ def print_c(json_file, output_file, argv):
json file
output file
$(SOURCE_ROOT)/build/scripts/c_templates/svn_interface.c"""
- def gen_header(info):
- lines = []
- for k, v in info.items():
- lines.append(_Formatting.escaped_define(k, v))
- return lines
-
interface = argv[0]
with open(interface) as c:
c_file = c.read()
with open(output_file, 'w') as f:
- header = '\n'.join(gen_header(json_file))
- if sys.version_info < (3, 0, 0):
- header = header.encode('utf-8')
+ header = '\n'.join(_Formatting.escaped_define(k, v) for k, v in json_file.items())
f.write(header + '\n' + c_file)
@@ -214,8 +199,8 @@ def print_java_mf(info):
return []
return wrapper.wrap(key + val)
- lines = wrap('Program-Version-String: ', base64.b64encode(info['PROGRAM_VERSION'].encode('utf-8')))
- lines += wrap('SCM-String: ', base64.b64encode(info['SCM_DATA'].encode('utf-8')))
+ lines = wrap('Program-Version-String: ', base64.b64encode(info['PROGRAM_VERSION'].encode('utf-8')).decode('utf-8'))
+ lines += wrap('SCM-String: ', base64.b64encode(info['SCM_DATA'].encode('utf-8')).decode('utf-8'))
lines += wrap('Arcadia-Source-Path: ', info['ARCADIA_SOURCE_PATH'])
lines += wrap('Arcadia-Source-URL: ', info['ARCADIA_SOURCE_URL'])
lines += wrap('Arcadia-Source-Revision: ', str(info['ARCADIA_SOURCE_REVISION']))
@@ -262,7 +247,7 @@ def print_go(json_file, output_file):
['func init() {',
' buildinfo.InitBuildInfo(buildinfomap)',
'}']
- ).encode('utf-8') + '\n')
+ ) + '\n')
if __name__ == '__main__':