diff options
author | rnefyodov <rnefyodov@yandex-team.ru> | 2022-02-10 16:47:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:17 +0300 |
commit | c753751b693cf7c481c0292912e2b7536fa6d36a (patch) | |
tree | 9814fbd1c3effac9b8377c5d604b367b14e2db55 /build/plugins/_common.py | |
parent | c22320e8c4f3d7be38c504706f137034e91d31e6 (diff) | |
download | ydb-c753751b693cf7c481c0292912e2b7536fa6d36a.tar.gz |
Restoring authorship annotation for <rnefyodov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/plugins/_common.py')
-rw-r--r-- | build/plugins/_common.py | 176 |
1 files changed, 88 insertions, 88 deletions
diff --git a/build/plugins/_common.py b/build/plugins/_common.py index e6ec69b909..2f831a94db 100644 --- a/build/plugins/_common.py +++ b/build/plugins/_common.py @@ -1,73 +1,73 @@ import sys -import hashlib +import hashlib import base64 - - -class Result(object): - pass - - -def lazy(func): - result = Result() - - def wrapper(): - try: - return result._result - except AttributeError: - result._result = func() - - return result._result - - return wrapper - - -def pathid(path): + + +class Result(object): + pass + + +def lazy(func): + result = Result() + + def wrapper(): + try: + return result._result + except AttributeError: + result._result = func() + + return result._result + + return wrapper + + +def pathid(path): return base64.b32encode(hashlib.md5(path).digest()).lower().strip('=') - - -def listid(l): - return pathid(str(sorted(l))) - - -def unpair(lst): - for x, y in lst: - yield x - yield y - - -def iterpair(lst): - y = None - - for x in lst: - if y: - yield (y, x) - - y = None - else: - y = x - - -def stripext(fname): - return fname[:fname.rfind('.')] - - -def tobuilddir(fname): + + +def listid(l): + return pathid(str(sorted(l))) + + +def unpair(lst): + for x, y in lst: + yield x + yield y + + +def iterpair(lst): + y = None + + for x in lst: + if y: + yield (y, x) + + y = None + else: + y = x + + +def stripext(fname): + return fname[:fname.rfind('.')] + + +def tobuilddir(fname): if not fname: return '$B' - if fname.startswith('$S'): - return fname.replace('$S', '$B', 1) - else: - return fname - - -def before(s, ss): - p = s.find(ss) - - if p == -1: - return s - - return s[:p] - + if fname.startswith('$S'): + return fname.replace('$S', '$B', 1) + else: + return fname + + +def before(s, ss): + p = s.find(ss) + + if p == -1: + return s + + return s[:p] + def sort_by_keywords(keywords, args): flat = [] @@ -139,32 +139,32 @@ def resolve_includes(unit, src, paths): return unit.resolve_include([src] + paths) if paths else [] -def rootrel_arc_src(src, unit): - if src.startswith('${ARCADIA_ROOT}/'): - return src[16:] - +def rootrel_arc_src(src, unit): + if src.startswith('${ARCADIA_ROOT}/'): + return src[16:] + if src.startswith('${ARCADIA_BUILD_ROOT}/'): return src[22:] - elif src.startswith('${CURDIR}/'): - return unit.path()[3:] + '/' + src[10:] - - else: - resolved = unit.resolve_arc_path(src) - - if resolved.startswith('$S/'): - return resolved[3:] - - return src # leave as is - - -def skip_build_root(x): - if x.startswith('${ARCADIA_BUILD_ROOT}'): - return x[len('${ARCADIA_BUILD_ROOT}'):].lstrip('/') - - return x - - + elif src.startswith('${CURDIR}/'): + return unit.path()[3:] + '/' + src[10:] + + else: + resolved = unit.resolve_arc_path(src) + + if resolved.startswith('$S/'): + return resolved[3:] + + return src # leave as is + + +def skip_build_root(x): + if x.startswith('${ARCADIA_BUILD_ROOT}'): + return x[len('${ARCADIA_BUILD_ROOT}'):].lstrip('/') + + return x + + def get_interpreter_path(): interpreter_path = [sys.executable] if 'ymake' in interpreter_path[0]: |