diff options
author | Stanislav Kirillov <staskirillov@gmail.com> | 2022-02-10 16:46:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:08 +0300 |
commit | cb68f224c46a8ee52ac3fdd2a32534b8bb8dc134 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /build/scripts/vcs_info.py | |
parent | 92fe2b1e7bc79f7b95adef61714fc003f6ea4a1c (diff) | |
download | ydb-cb68f224c46a8ee52ac3fdd2a32534b8bb8dc134.tar.gz |
Restoring authorship annotation for Stanislav Kirillov <staskirillov@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/vcs_info.py')
-rw-r--r-- | build/scripts/vcs_info.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/build/scripts/vcs_info.py b/build/scripts/vcs_info.py index 01142134c2..319d1b4631 100644 --- a/build/scripts/vcs_info.py +++ b/build/scripts/vcs_info.py @@ -11,34 +11,34 @@ 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) - - @staticmethod - def encoding_needed(strval): - if sys.version_info >= (3, 0, 0): - return isinstance(strval, str) - else: - return isinstance(strval, unicode) - - @staticmethod + def is_str(strval): + if sys.version_info >= (3, 0, 0): + return isinstance(strval, (bytes,str)) + else: + return isinstance(strval, basestring) + + @staticmethod + def encoding_needed(strval): + if sys.version_info >= (3, 0, 0): + return isinstance(strval, str) + else: + return isinstance(strval, unicode) + + @staticmethod def escape_special_symbols(strval): - encoding_needed = _Formatting.encoding_needed(strval) - c_str = strval.encode('utf-8') if encoding_needed else strval - retval = b"" + encoding_needed = _Formatting.encoding_needed(strval) + 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]) + if sys.version_info >= (3, 0, 0): + c = bytes([c]) if c in ("\\", "\""): retval += "\\" + c elif ord(c) < ord(' '): - retval += c.decode('latin-1').encode('unicode_escape') + retval += c.decode('latin-1').encode('unicode_escape') else: retval += c - return retval.decode('utf-8') if encoding_needed else retval + return retval.decode('utf-8') if encoding_needed else retval @staticmethod def escape_line_feed(strval, indent=' '): @@ -51,7 +51,7 @@ class _Formatting(object): @staticmethod def escaped_define(strkey, val): name = "#define " + strkey + " " - if _Formatting.is_str(val): + if _Formatting.is_str(val): define = "\"" + _Formatting.escape_line_feed( _Formatting.escape_trigraphs(_Formatting.escape_special_symbols(val))) + "\"" else: @@ -60,7 +60,7 @@ class _Formatting(object): @staticmethod def escaped_go_map_key(strkey, strval): - if _Formatting.is_str(strval): + if _Formatting.is_str(strval): return ' ' + '"' + strkey + '": "' + _Formatting.escape_special_symbols(strval) + '",' else: return ' ' + '"' + strkey + '": "' + str(strval) + '",' @@ -94,7 +94,7 @@ def get_json(file_name): # 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]): + if i in out and _Formatting.is_str(out[i]): try: out[i] = int(out[i]) except: @@ -120,10 +120,10 @@ def print_c(json_file, output_file, argv): 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') - f.write(header + '\n' + c_file) + header = '\n'.join(gen_header(json_file)) + if sys.version_info < (3, 0, 0): + header = header.encode('utf-8') + f.write(header + '\n' + c_file) def merge_java_content(old_content, json_file): |