Browse Source

Restoring authorship annotation for <akastornov@yandex-team.ru>. Commit 1 of 2.

akastornov 3 years ago
parent
commit
3a2de774d9

+ 96 - 96
build/plugins/java.py

@@ -1,43 +1,43 @@
-import _common as common
+import _common as common 
 import ymake
-import json
+import json 
 import os
-import base64
-
-
-DELIM = '================================'
-
-
-def split_args(s):  # TODO quotes, escapes
-    return filter(None, s.split())
-
-
-def extract_macro_calls(unit, macro_value_name, macro_calls_delim):
-    if not unit.get(macro_value_name):
-        return []
-
-    return filter(None, map(split_args, unit.get(macro_value_name).replace('$' + macro_value_name, '').split(macro_calls_delim)))
-
-
-def extract_macro_calls2(unit, macro_value_name):
-    if not unit.get(macro_value_name):
-        return []
-
-    calls = []
-    for call_encoded_args in unit.get(macro_value_name).strip().split():
-        call_args = json.loads(base64.b64decode(call_encoded_args), encoding='utf-8')
-        calls.append(call_args)
-
-    return calls
-
-
+import base64 
+ 
+ 
+DELIM = '================================' 
+ 
+ 
+def split_args(s):  # TODO quotes, escapes 
+    return filter(None, s.split()) 
+ 
+ 
+def extract_macro_calls(unit, macro_value_name, macro_calls_delim): 
+    if not unit.get(macro_value_name): 
+        return [] 
+ 
+    return filter(None, map(split_args, unit.get(macro_value_name).replace('$' + macro_value_name, '').split(macro_calls_delim))) 
+ 
+ 
+def extract_macro_calls2(unit, macro_value_name): 
+    if not unit.get(macro_value_name): 
+        return [] 
+ 
+    calls = [] 
+    for call_encoded_args in unit.get(macro_value_name).strip().split(): 
+        call_args = json.loads(base64.b64decode(call_encoded_args), encoding='utf-8') 
+        calls.append(call_args) 
+ 
+    return calls 
+ 
+ 
 def on_run_jbuild_program(unit, *args):
     args = list(args)
     """
     Custom code generation
     @link: https://wiki.yandex-team.ru/yatool/java/#kodogeneracijarunjavaprogram
     """
-
+ 
     flat, kv = common.sort_by_keywords({'IN': -1, 'IN_DIR': -1, 'OUT': -1, 'OUT_DIR': -1, 'CWD': 1, 'CLASSPATH': -1, 'CP_USE_COMMAND_FILE': 1, 'ADD_SRCS_TO_CLASSPATH': 0}, args)
     depends = kv.get('CLASSPATH', []) + kv.get('JAR', [])
     fake_out = None
@@ -45,18 +45,18 @@ def on_run_jbuild_program(unit, *args):
         # XXX: hack to force ymake to build dependencies
         fake_out = "fake.out.{}".format(hash(tuple(args)))
         unit.on_run_java(['TOOL'] + depends + ["OUT", fake_out])
-
+ 
     if not kv.get('CP_USE_COMMAND_FILE'):
        args += ['CP_USE_COMMAND_FILE', unit.get(['JAVA_PROGRAM_CP_USE_COMMAND_FILE']) or 'yes']
 
     if fake_out is not None:
         args += ['FAKE_OUT', fake_out]
 
-    prev = unit.get(['RUN_JAVA_PROGRAM_VALUE']) or ''
-    new_val = (prev + ' ' + base64.b64encode(json.dumps(list(args), encoding='utf-8'))).strip()
-    unit.set(['RUN_JAVA_PROGRAM_VALUE', new_val])
-
-
+    prev = unit.get(['RUN_JAVA_PROGRAM_VALUE']) or '' 
+    new_val = (prev + ' ' + base64.b64encode(json.dumps(list(args), encoding='utf-8'))).strip() 
+    unit.set(['RUN_JAVA_PROGRAM_VALUE', new_val]) 
+ 
+ 
 def ongenerate_script(unit, *args):
     """
     heretic@ promised to make tutorial here
@@ -74,48 +74,48 @@ def ongenerate_script(unit, *args):
     unit.set(['GENERATE_SCRIPT_VALUE', new_val])
 
 
-def onjava_module(unit, *args):
-    args_delim = unit.get('ARGS_DELIM')
+def onjava_module(unit, *args): 
+    args_delim = unit.get('ARGS_DELIM') 
     idea_only = True if 'IDEA_ONLY' in args else False
-
+ 
     if idea_only:
         if unit.get('YA_IDE_IDEA') != 'yes':
             return
         if unit.get('YMAKE_JAVA_MODULES') != 'yes':
             return
 
-    data = {
+    data = { 
         'BUNDLE_NAME': unit.name(),
-        'PATH': unit.path(),
+        'PATH': unit.path(), 
         'IDEA_ONLY': 'yes' if idea_only else 'no',
-        'MODULE_TYPE': unit.get('MODULE_TYPE'),
-        'MODULE_ARGS': unit.get('MODULE_ARGS'),
+        'MODULE_TYPE': unit.get('MODULE_TYPE'), 
+        'MODULE_ARGS': unit.get('MODULE_ARGS'), 
         'MANAGED_PEERS': '${MANAGED_PEERS}',
         'MANAGED_PEERS_CLOSURE': '${MANAGED_PEERS_CLOSURE}',
         'NON_NAMAGEABLE_PEERS': '${NON_NAMAGEABLE_PEERS}',
         'TEST_CLASSPATH_MANAGED': '${TEST_CLASSPATH_MANAGED}',
-        'EXCLUDE': extract_macro_calls(unit, 'EXCLUDE_VALUE', args_delim),
-        'JAVA_SRCS': extract_macro_calls(unit, 'JAVA_SRCS_VALUE', args_delim),
-        'JAVAC_FLAGS': extract_macro_calls(unit, 'JAVAC_FLAGS_VALUE', args_delim),
-        'ANNOTATION_PROCESSOR': extract_macro_calls(unit, 'ANNOTATION_PROCESSOR_VALUE', args_delim),
-        'EXTERNAL_JAR': extract_macro_calls(unit, 'EXTERNAL_JAR_VALUE', args_delim),
-        'RUN_JAVA_PROGRAM': extract_macro_calls2(unit, 'RUN_JAVA_PROGRAM_VALUE'),
+        'EXCLUDE': extract_macro_calls(unit, 'EXCLUDE_VALUE', args_delim), 
+        'JAVA_SRCS': extract_macro_calls(unit, 'JAVA_SRCS_VALUE', args_delim), 
+        'JAVAC_FLAGS': extract_macro_calls(unit, 'JAVAC_FLAGS_VALUE', args_delim), 
+        'ANNOTATION_PROCESSOR': extract_macro_calls(unit, 'ANNOTATION_PROCESSOR_VALUE', args_delim), 
+        'EXTERNAL_JAR': extract_macro_calls(unit, 'EXTERNAL_JAR_VALUE', args_delim), 
+        'RUN_JAVA_PROGRAM': extract_macro_calls2(unit, 'RUN_JAVA_PROGRAM_VALUE'), 
         'RUN_JAVA_PROGRAM_MANAGED': '${RUN_JAVA_PROGRAM_MANAGED}',
         'MAVEN_GROUP_ID': extract_macro_calls(unit, 'MAVEN_GROUP_ID_VALUE', args_delim),
         'JAR_INCLUDE_FILTER': extract_macro_calls(unit, 'JAR_INCLUDE_FILTER_VALUE', args_delim),
         'JAR_EXCLUDE_FILTER': extract_macro_calls(unit, 'JAR_EXCLUDE_FILTER_VALUE', args_delim),
-
-        # TODO remove when java test dart is in prod
-        'UNITTEST_DIR': unit.get('UNITTEST_DIR'),
-        'SYSTEM_PROPERTIES': extract_macro_calls(unit, 'SYSTEM_PROPERTIES_VALUE', args_delim),
-        'JVM_ARGS': extract_macro_calls(unit, 'JVM_ARGS_VALUE', args_delim),
-        'TEST_CWD': extract_macro_calls(unit, 'TEST_CWD_VALUE', args_delim),
-        'TEST_DATA': extract_macro_calls(unit, '__test_data', args_delim),
-        'TEST_FORK_MODE': extract_macro_calls(unit, 'TEST_FORK_MODE', args_delim),
-        'SPLIT_FACTOR': extract_macro_calls(unit, 'TEST_SPLIT_FACTOR', args_delim),
-        'TIMEOUT': extract_macro_calls(unit, 'TEST_TIMEOUT', args_delim),
-        'TAG': extract_macro_calls(unit, 'TEST_TAGS_VALUE', args_delim),
-        'SIZE': extract_macro_calls(unit, 'TEST_SIZE_NAME', args_delim),
+ 
+        # TODO remove when java test dart is in prod 
+        'UNITTEST_DIR': unit.get('UNITTEST_DIR'), 
+        'SYSTEM_PROPERTIES': extract_macro_calls(unit, 'SYSTEM_PROPERTIES_VALUE', args_delim), 
+        'JVM_ARGS': extract_macro_calls(unit, 'JVM_ARGS_VALUE', args_delim), 
+        'TEST_CWD': extract_macro_calls(unit, 'TEST_CWD_VALUE', args_delim), 
+        'TEST_DATA': extract_macro_calls(unit, '__test_data', args_delim), 
+        'TEST_FORK_MODE': extract_macro_calls(unit, 'TEST_FORK_MODE', args_delim), 
+        'SPLIT_FACTOR': extract_macro_calls(unit, 'TEST_SPLIT_FACTOR', args_delim), 
+        'TIMEOUT': extract_macro_calls(unit, 'TEST_TIMEOUT', args_delim), 
+        'TAG': extract_macro_calls(unit, 'TEST_TAGS_VALUE', args_delim), 
+        'SIZE': extract_macro_calls(unit, 'TEST_SIZE_NAME', args_delim), 
         'DEPENDS': extract_macro_calls(unit, 'TEST_DEPENDS_VALUE', args_delim),
         'IDEA_EXCLUDE': extract_macro_calls(unit, 'IDEA_EXCLUDE_DIRS_VALUE', args_delim),
         'IDEA_RESOURCE': extract_macro_calls(unit, 'IDEA_RESOURCE_DIRS_VALUE', args_delim),
@@ -125,17 +125,17 @@ def onjava_module(unit, *args):
         'TEST_DATA': extract_macro_calls(unit, 'TEST_DATA_VALUE', args_delim),
         'JAVA_FORBIDDEN_LIBRARIES': extract_macro_calls(unit, 'JAVA_FORBIDDEN_LIBRARIES_VALUE', args_delim),
         'JDK_RESOURCE': 'JDK' + (unit.get('JDK_VERSION') or '_DEFAULT')
-    }
+    } 
     if unit.get('ENABLE_PREVIEW_VALUE') == 'yes' and unit.get('JDK_VERSION') in ('15', '16', '17'):
         data['ENABLE_PREVIEW'] = extract_macro_calls(unit, 'ENABLE_PREVIEW_VALUE', args_delim)
 
     if unit.get('SAVE_JAVAC_GENERATED_SRCS_DIR') and unit.get('SAVE_JAVAC_GENERATED_SRCS_TAR'):
         data['SAVE_JAVAC_GENERATED_SRCS_DIR'] = extract_macro_calls(unit, 'SAVE_JAVAC_GENERATED_SRCS_DIR', args_delim)
         data['SAVE_JAVAC_GENERATED_SRCS_TAR'] = extract_macro_calls(unit, 'SAVE_JAVAC_GENERATED_SRCS_TAR', args_delim)
-
+ 
     if unit.get('JAVA_ADD_DLLS_VALUE') == 'yes':
         data['ADD_DLLS_FROM_DEPENDS'] = extract_macro_calls(unit, 'JAVA_ADD_DLLS_VALUE', args_delim)
-
+ 
     if unit.get('ERROR_PRONE_VALUE') == 'yes':
         data['ERROR_PRONE'] = extract_macro_calls(unit, 'ERROR_PRONE_VALUE', args_delim)
 
@@ -189,36 +189,36 @@ def onjava_module(unit, *args):
         if macro_str and macro_str == 'yes':
             data['VCS_INFO_DISABLE_CACHE__NO_UID__'] = macro_val
 
-    for java_srcs_args in data['JAVA_SRCS']:
-        external = None
-
-        for i in xrange(len(java_srcs_args)):
-            arg = java_srcs_args[i]
-
-            if arg == 'EXTERNAL':
-                if not i + 1 < len(java_srcs_args):
-                    continue  # TODO configure error
-
-                ex = java_srcs_args[i + 1]
-
-                if ex in ('EXTERNAL', 'SRCDIR', 'PACKAGE_PREFIX', 'EXCLUDE'):
-                    continue  # TODO configure error
-
-                if external is not None:
-                    continue  # TODO configure error
-
-                external = ex
-
-        if external:
-            unit.onpeerdir(external)
-
-    for k, v in data.items():
-        if not v:
-            data.pop(k)
-
-    dart = 'JAVA_DART: ' + base64.b64encode(json.dumps(data)) + '\n' + DELIM + '\n'
-
-    unit.set_property(['JAVA_DART_DATA', dart])
+    for java_srcs_args in data['JAVA_SRCS']: 
+        external = None 
+ 
+        for i in xrange(len(java_srcs_args)): 
+            arg = java_srcs_args[i] 
+ 
+            if arg == 'EXTERNAL': 
+                if not i + 1 < len(java_srcs_args): 
+                    continue  # TODO configure error 
+ 
+                ex = java_srcs_args[i + 1] 
+ 
+                if ex in ('EXTERNAL', 'SRCDIR', 'PACKAGE_PREFIX', 'EXCLUDE'): 
+                    continue  # TODO configure error 
+ 
+                if external is not None: 
+                    continue  # TODO configure error 
+ 
+                external = ex 
+ 
+        if external: 
+            unit.onpeerdir(external) 
+ 
+    for k, v in data.items(): 
+        if not v: 
+            data.pop(k) 
+ 
+    dart = 'JAVA_DART: ' + base64.b64encode(json.dumps(data)) + '\n' + DELIM + '\n' 
+ 
+    unit.set_property(['JAVA_DART_DATA', dart]) 
     if not idea_only and unit.get('MODULE_TYPE') in ('JAVA_PROGRAM', 'JAVA_LIBRARY', 'JTEST', 'TESTNG', 'JUNIT5') and not unit.path().startswith('$S/contrib/java'):
         unit.on_add_classpath_clash_check()
         if unit.get('LINT_LEVEL_VALUE') != "none":

+ 2 - 2
build/plugins/pybuild.py

@@ -498,7 +498,7 @@ def onpy_srcs(unit, *args):
             unit.onpeerdir(py_runtime_path)
 
         unit.onpeerdir(unit.get("PY_PROTO_DEPS").split())
-
+ 
         proto_paths = [path for path, mod in protos]
         unit.on_generate_py_protos_internal(proto_paths)
         unit.onpy_srcs([
@@ -506,7 +506,7 @@ def onpy_srcs(unit, *args):
             for path, mod in protos
             for py_suf in unit.get("PY_PROTO_SUFFIXES").split()
         ])
-
+ 
         if optimize_proto and need_gazetteer_peerdir:
             unit.onpeerdir(['kernel/gazetteer/proto'])
 

+ 57 - 57
build/plugins/scarab_cant_clash.py

@@ -1,65 +1,65 @@
-import _common as common
-
-
-def onacceleo(unit, *args):
+import _common as common 
+ 
+ 
+def onacceleo(unit, *args): 
     if unit.get("YMAKE_JAVA_MODULES") == "yes":
         return
-    flat, kv = common.sort_by_keywords(
+    flat, kv = common.sort_by_keywords( 
         {'XSD': -1, 'MTL': -1, 'MTL_ROOT': 1, 'LANG': -1, 'OUT': -1, 'OUT_NOAUTO': -1, 'OUTPUT_INCLUDES': -1, 'DEBUG': 0},
-        args
-    )
-
-    try:
-        mtlroot = kv['MTL_ROOT'][0]
-    except Exception:
-        mtlroot = unit.path().replace('$S/', '')
-
-    classpath = ['$SCARAB', ]  # XXX special word for ya make to replace following paths with real classpath
-    classpath.append('tools/acceleo')
-
+        args 
+    ) 
+ 
+    try: 
+        mtlroot = kv['MTL_ROOT'][0] 
+    except Exception: 
+        mtlroot = unit.path().replace('$S/', '') 
+ 
+    classpath = ['$SCARAB', ]  # XXX special word for ya make to replace following paths with real classpath 
+    classpath.append('tools/acceleo') 
+ 
     depends = []
-    if not unit.get('IDE_MSVS_CALL'):
-        for jar in classpath[1:]:
+    if not unit.get('IDE_MSVS_CALL'): 
+        for jar in classpath[1:]: 
             depends.append(jar)
-
-    classpath = ':'.join(classpath)
-
-    # Generate java cmd
-    cmd = [
-        '-classpath',
-        classpath,
-        '-Dfile.encoding=UTF-8',
-        'ru.yandex.se.logsng.tool.Cli',
-    ]
-
-    for xsd in kv.get('XSD', []):
-        cmd += ['--xsd', xsd]
-
-    for mtl in kv.get('MTL', []):
-        cmd += ['--mtl', mtl]
-
-    for lang in kv.get('LANG', []):
-        cmd += ['--lang', lang]
-
-    cmd += ['--output-dir', unit.path().replace('$S/', '${ARCADIA_BUILD_ROOT}/')]
-    cmd += ['--build-root', '${ARCADIA_BUILD_ROOT}']
-    cmd += ['--source-root', '${ARCADIA_ROOT}']
-    cmd += ['--mtl-root', mtlroot]
-
-    # Generate RUN_JAVA args
-    run_java = cmd
-
-    if 'DEBUG' not in kv:
-        run_java += ['HIDE_OUTPUT']
-
-    inputs = kv.get('XSD', []) + kv.get('MTL', []) + kv.get('LANG', [])
-    if inputs:
-        run_java += ['IN'] + inputs
-
-    for k in 'OUT', 'OUT_NOAUTO', 'OUTPUT_INCLUDES':
-        if kv.get(k):
-            run_java += [k] + kv[k]
-
+ 
+    classpath = ':'.join(classpath) 
+ 
+    # Generate java cmd 
+    cmd = [ 
+        '-classpath', 
+        classpath, 
+        '-Dfile.encoding=UTF-8', 
+        'ru.yandex.se.logsng.tool.Cli', 
+    ] 
+ 
+    for xsd in kv.get('XSD', []): 
+        cmd += ['--xsd', xsd] 
+ 
+    for mtl in kv.get('MTL', []): 
+        cmd += ['--mtl', mtl] 
+ 
+    for lang in kv.get('LANG', []): 
+        cmd += ['--lang', lang] 
+ 
+    cmd += ['--output-dir', unit.path().replace('$S/', '${ARCADIA_BUILD_ROOT}/')] 
+    cmd += ['--build-root', '${ARCADIA_BUILD_ROOT}'] 
+    cmd += ['--source-root', '${ARCADIA_ROOT}'] 
+    cmd += ['--mtl-root', mtlroot] 
+ 
+    # Generate RUN_JAVA args 
+    run_java = cmd 
+ 
+    if 'DEBUG' not in kv: 
+        run_java += ['HIDE_OUTPUT'] 
+ 
+    inputs = kv.get('XSD', []) + kv.get('MTL', []) + kv.get('LANG', []) 
+    if inputs: 
+        run_java += ['IN'] + inputs 
+ 
+    for k in 'OUT', 'OUT_NOAUTO', 'OUTPUT_INCLUDES': 
+        if kv.get(k): 
+            run_java += [k] + kv[k] 
+ 
     if depends:
         run_java += ['TOOL'] + depends
 

+ 56 - 56
build/plugins/ytest.py

@@ -1,9 +1,9 @@
 import os
 import re
 import sys
-import json
+import json 
 import copy
-import base64
+import base64 
 import shlex
 import _common
 import lib._metric_resolvers as mr
@@ -348,7 +348,7 @@ def count_entries(x):
 
 
 def get_values_list(unit, key):
-    res = map(str.strip, (unit.get(key) or '').replace('$' + key, '').strip().split())
+    res = map(str.strip, (unit.get(key) or '').replace('$' + key, '').strip().split()) 
     return [r for r in res if r and r not in ['""', "''"]]
 
 
@@ -416,7 +416,7 @@ def get_project_tidy_config(unit):
 def onadd_ytest(unit, *args):
     keywords = {"DEPENDS": -1, "DATA": -1, "TIMEOUT": 1, "FORK_MODE": 1, "SPLIT_FACTOR": 1,
                 "FORK_SUBTESTS": 0, "FORK_TESTS": 0}
-    flat_args, spec_args = _common.sort_by_keywords(keywords, args)
+    flat_args, spec_args = _common.sort_by_keywords(keywords, args) 
 
     test_data = sorted(_common.filter_out_by_keyword(spec_args.get('DATA', []) + get_norm_paths(unit, 'TEST_DATA_VALUE'), 'AUTOUPDATED'))
 
@@ -547,7 +547,7 @@ def onadd_check(unit, *args):
     if unit.get("TIDY") == "yes":
         # graph changed for clang_tidy tests
         return
-    flat_args, spec_args = _common.sort_by_keywords({"DEPENDS": -1, "TIMEOUT": 1, "DATA": -1, "TAG": -1, "REQUIREMENTS": -1, "FORK_MODE": 1,
+    flat_args, spec_args = _common.sort_by_keywords({"DEPENDS": -1, "TIMEOUT": 1, "DATA": -1, "TAG": -1, "REQUIREMENTS": -1, "FORK_MODE": 1, 
                                                      "SPLIT_FACTOR": 1, "FORK_SUBTESTS": 0, "FORK_TESTS": 0, "SIZE": 1}, args)
     check_type = flat_args[0]
     test_dir = get_norm_unit_path(unit)
@@ -770,40 +770,40 @@ def add_test_to_dart(unit, test_type, binary_path=None, runner_bin=None):
     _dump_test(unit, test_type, test_files, timeout, get_norm_unit_path(unit), custom_deps, test_data, python_paths, split_factor, fork_mode, test_size, tags, requirements, binary_path, test_cwd=test_cwd, runner_bin=runner_bin, yt_spec=yt_spec, data_files=data_files)
 
 
-def extract_java_system_properties(unit, args):
-    if len(args) % 2:
+def extract_java_system_properties(unit, args): 
+    if len(args) % 2: 
         return [], 'Wrong use of SYSTEM_PROPERTIES in {}: odd number of arguments'.format(unit.path())
-
+ 
     props = []
-    for x, y in zip(args[::2], args[1::2]):
-        if x == 'FILE':
-            if y.startswith('${BINDIR}') or y.startswith('${ARCADIA_BUILD_ROOT}') or y.startswith('/'):
+    for x, y in zip(args[::2], args[1::2]): 
+        if x == 'FILE': 
+            if y.startswith('${BINDIR}') or y.startswith('${ARCADIA_BUILD_ROOT}') or y.startswith('/'): 
                 return [], 'Wrong use of SYSTEM_PROPERTIES in {}: absolute/build file path {}'.format(unit.path(), y)
-
-            y = _common.rootrel_arc_src(y, unit)
-            if not os.path.exists(unit.resolve('$S/' + y)):
+ 
+            y = _common.rootrel_arc_src(y, unit) 
+            if not os.path.exists(unit.resolve('$S/' + y)): 
                 return [], 'Wrong use of SYSTEM_PROPERTIES in {}: can\'t resolve {}'.format(unit.path(), y)
-
-            y = '${ARCADIA_ROOT}/' + y
-            props.append({'type': 'file', 'path': y})
-        else:
-            props.append({'type': 'inline', 'key': x, 'value': y})
-
+ 
+            y = '${ARCADIA_ROOT}/' + y 
+            props.append({'type': 'file', 'path': y}) 
+        else: 
+            props.append({'type': 'inline', 'key': x, 'value': y}) 
+ 
     return props, None
-
-
-def onjava_test(unit, *args):
+ 
+ 
+def onjava_test(unit, *args): 
     if unit.get("TIDY") == "yes":
         # graph changed for clang_tidy tests
         return
 
-    assert unit.get('MODULE_TYPE') is not None
-
-    if unit.get('MODULE_TYPE') == 'JTEST_FOR':
-        if not unit.get('UNITTEST_DIR'):
+    assert unit.get('MODULE_TYPE') is not None 
+ 
+    if unit.get('MODULE_TYPE') == 'JTEST_FOR': 
+        if not unit.get('UNITTEST_DIR'): 
             ymake.report_configure_error('skip JTEST_FOR in {}: no args provided'.format(unit.path()))
             return
-
+ 
     java_cp_arg_type = unit.get('JAVA_CLASSPATH_CMD_TYPE_VALUE') or 'MANIFEST'
     if java_cp_arg_type not in ('MANIFEST', 'COMMAND_FILE', 'LIST'):
         ymake.report_configure_error('{}: TEST_JAVA_CLASSPATH_CMD_TYPE({}) are invalid. Choose argument from MANIFEST, COMMAND_FILE or LIST)'.format(unit.path(), java_cp_arg_type))
@@ -811,11 +811,11 @@ def onjava_test(unit, *args):
 
     unit_path = unit.path()
     path = _common.strip_roots(unit_path)
-
+ 
     test_data = get_norm_paths(unit, 'TEST_DATA_VALUE')
     test_data.append('arcadia/build/scripts/run_junit.py')
     test_data.append('arcadia/build/scripts/unpacking_jtest_runner.py')
-
+ 
     data, data_files = get_canonical_test_resources(unit)
     test_data += data
 
@@ -823,49 +823,49 @@ def onjava_test(unit, *args):
     if error_mgs:
         ymake.report_configure_error(error_mgs)
         return
-    for prop in props:
-        if prop['type'] == 'file':
-            test_data.append(prop['path'].replace('${ARCADIA_ROOT}', 'arcadia'))
-
-    props = base64.b64encode(json.dumps(props, encoding='utf-8'))
-
-    test_cwd = unit.get('TEST_CWD_VALUE') or ''  # TODO: validate test_cwd value
-
+    for prop in props: 
+        if prop['type'] == 'file': 
+            test_data.append(prop['path'].replace('${ARCADIA_ROOT}', 'arcadia')) 
+ 
+    props = base64.b64encode(json.dumps(props, encoding='utf-8')) 
+ 
+    test_cwd = unit.get('TEST_CWD_VALUE') or ''  # TODO: validate test_cwd value 
+ 
     if unit.get('MODULE_TYPE') == 'JUNIT5':
         script_rel_path = 'junit5.test'
     else:
         script_rel_path = 'junit.test'
 
     ymake_java_test = unit.get('YMAKE_JAVA_TEST') == 'yes'
-    test_record = {
-        'SOURCE-FOLDER-PATH': path,
-        'TEST-NAME': '-'.join([os.path.basename(os.path.dirname(path)), os.path.basename(path)]),
+    test_record = { 
+        'SOURCE-FOLDER-PATH': path, 
+        'TEST-NAME': '-'.join([os.path.basename(os.path.dirname(path)), os.path.basename(path)]), 
         'SCRIPT-REL-PATH': script_rel_path,
         'TEST-TIMEOUT': unit.get('TEST_TIMEOUT') or '',
         'TESTED-PROJECT-NAME': path,
         'TEST-ENV': prepare_env(unit.get("TEST_ENV_VALUE")),
         #  'TEST-PRESERVE-ENV': 'da',
         'TEST-DATA': serialize_list(sorted(_common.filter_out_by_keyword(test_data, 'AUTOUPDATED'))),
-        'FORK-MODE': unit.get('TEST_FORK_MODE') or '',
-        'SPLIT-FACTOR': unit.get('TEST_SPLIT_FACTOR') or '',
-        'CUSTOM-DEPENDENCIES': ' '.join(get_values_list(unit, 'TEST_DEPENDS_VALUE')),
+        'FORK-MODE': unit.get('TEST_FORK_MODE') or '', 
+        'SPLIT-FACTOR': unit.get('TEST_SPLIT_FACTOR') or '', 
+        'CUSTOM-DEPENDENCIES': ' '.join(get_values_list(unit, 'TEST_DEPENDS_VALUE')), 
         'TAG': serialize_list(_get_test_tags(unit)),
-        'SIZE': unit.get('TEST_SIZE_NAME') or '',
+        'SIZE': unit.get('TEST_SIZE_NAME') or '', 
         'REQUIREMENTS': serialize_list(get_values_list(unit, 'TEST_REQUIREMENTS_VALUE')),
         'TEST-RECIPES': prepare_recipes(unit.get("TEST_RECIPES_VALUE")),
-
-        # JTEST/JTEST_FOR only
-        'MODULE_TYPE': unit.get('MODULE_TYPE'),
-        'UNITTEST_DIR': unit.get('UNITTEST_DIR') or '',
-        'JVM_ARGS': serialize_list(get_values_list(unit, 'JVM_ARGS_VALUE')),
-        'SYSTEM_PROPERTIES': props,
-        'TEST-CWD': test_cwd,
+ 
+        # JTEST/JTEST_FOR only 
+        'MODULE_TYPE': unit.get('MODULE_TYPE'), 
+        'UNITTEST_DIR': unit.get('UNITTEST_DIR') or '', 
+        'JVM_ARGS': serialize_list(get_values_list(unit, 'JVM_ARGS_VALUE')), 
+        'SYSTEM_PROPERTIES': props, 
+        'TEST-CWD': test_cwd, 
         'SKIP_TEST': unit.get('SKIP_TEST_VALUE') or '',
         'JAVA_CLASSPATH_CMD_TYPE': java_cp_arg_type,
         'NO_JBUILD': 'yes' if ymake_java_test else 'no',
         'JDK_RESOURCE': 'JDK' + (unit.get('JDK_VERSION') or '_DEFAULT'),
         'JDK_FOR_TESTS': 'JDK' + (unit.get('JDK_VERSION') or '_DEFAULT') + '_FOR_TESTS',
-    }
+    } 
     test_classpath_origins = unit.get('TEST_CLASSPATH_VALUE')
     if test_classpath_origins:
         test_record['TEST_CLASSPATH_ORIGINS'] = test_classpath_origins
@@ -877,12 +877,12 @@ def onjava_test(unit, *args):
             test_record['TEST_JAR'] = '${UNITTEST_MOD}'
         else:
             test_record['TEST_JAR'] = '{}/{}.jar'.format(unit.get('MODDIR'), unit.get('REALPRJNAME'))
-
+ 
     data = dump_test(unit, test_record)
     if data:
         unit.set_property(['DART_DATA', data])
-
-
+ 
+ 
 def onjava_test_deps(unit, *args):
     if unit.get("TIDY") == "yes":
         # graph changed for clang_tidy tests

+ 41 - 41
build/scripts/collect_java_srcs.py

@@ -1,51 +1,51 @@
-import os
-import sys
-import contextlib
-import tarfile
-import zipfile
-
-
-if __name__ == '__main__':
-    build_root = sys.argv[1]
+import os 
+import sys 
+import contextlib 
+import tarfile 
+import zipfile 
+ 
+ 
+if __name__ == '__main__': 
+    build_root = sys.argv[1] 
     root = os.path.normpath(sys.argv[2])
     dest = os.path.normpath(sys.argv[3])
-    srcs = sys.argv[4:]
-
-    for src in srcs:
+    srcs = sys.argv[4:] 
+ 
+    for src in srcs: 
         src = os.path.normpath(src)
         if src.endswith('.java') or src.endswith('.kt'):
-            src_rel_path = os.path.relpath(src, root)
-
-            if os.path.join(root, src_rel_path) == src:
-                # Inside root
-                dst = os.path.join(dest, src_rel_path)
-
-            else:
-                # Outside root
+            src_rel_path = os.path.relpath(src, root) 
+ 
+            if os.path.join(root, src_rel_path) == src: 
+                # Inside root 
+                dst = os.path.join(dest, src_rel_path) 
+ 
+            else: 
+                # Outside root 
                 print>>sys.stderr, 'External src file "{}" is outside of srcdir {}, ignore'.format(
-                    os.path.relpath(src, build_root),
-                    os.path.relpath(root, build_root),
-                )
-                continue
-
-            if os.path.exists(dst):
-                print>>sys.stderr, 'Duplicate external src file {}, choice is undefined'.format(
-                    os.path.relpath(dst, root)
-                )
-
-            else:
+                    os.path.relpath(src, build_root), 
+                    os.path.relpath(root, build_root), 
+                ) 
+                continue 
+ 
+            if os.path.exists(dst): 
+                print>>sys.stderr, 'Duplicate external src file {}, choice is undefined'.format( 
+                    os.path.relpath(dst, root) 
+                ) 
+ 
+            else: 
                 destdir = os.path.dirname(dst)
                 if destdir and not os.path.exists(destdir):
                     os.makedirs(destdir)
                 os.rename(src, dst)
-
-        elif src.endswith('.jsr'):
-            with contextlib.closing(tarfile.open(src, 'r')) as tf:
-                tf.extractall(dst)
-
-        elif src.endswith('-sources.jar'):
+ 
+        elif src.endswith('.jsr'): 
+            with contextlib.closing(tarfile.open(src, 'r')) as tf: 
+                tf.extractall(dst) 
+ 
+        elif src.endswith('-sources.jar'): 
             with zipfile.ZipFile(src) as zf:
-                zf.extractall(dst)
-
-        else:
-            print>>sys.stderr, 'Unrecognized file type', os.path.relpath(src, build_root)
+                zf.extractall(dst) 
+ 
+        else: 
+            print>>sys.stderr, 'Unrecognized file type', os.path.relpath(src, build_root) 

+ 66 - 66
build/scripts/compile_java.py

@@ -1,29 +1,29 @@
-import optparse
-import contextlib
-import os
-import shutil
-import subprocess as sp
-import tarfile
-import zipfile
+import optparse 
+import contextlib 
+import os 
+import shutil 
+import subprocess as sp 
+import tarfile 
+import zipfile 
 import sys
-
-
+ 
+ 
 def parse_args(args):
-    parser = optparse.OptionParser()
-    parser.add_option('--javac-bin')
-    parser.add_option('--jar-bin')
+    parser = optparse.OptionParser() 
+    parser.add_option('--javac-bin') 
+    parser.add_option('--jar-bin') 
     parser.add_option('--vcs-mf')
-    parser.add_option('--package-prefix')
-    parser.add_option('--jar-output')
-    parser.add_option('--srcs-jar-output')
+    parser.add_option('--package-prefix') 
+    parser.add_option('--jar-output') 
+    parser.add_option('--srcs-jar-output') 
     return parser.parse_args(args)
-
-
-def mkdir_p(directory):
-    if not os.path.exists(directory):
-        os.makedirs(directory)
-
-
+ 
+ 
+def mkdir_p(directory): 
+    if not os.path.exists(directory): 
+        os.makedirs(directory) 
+ 
+ 
 def split_cmd_by_delim(cmd, delim='DELIM'):
     result = [[]]
     for arg in cmd:
@@ -34,69 +34,69 @@ def split_cmd_by_delim(cmd, delim='DELIM'):
     return result
 
 
-def main():
+def main(): 
     cmd_parts = split_cmd_by_delim(sys.argv)
     assert len(cmd_parts) == 3
     args, javac_opts, peers = cmd_parts
     opts, jsrcs = parse_args(args)
-
+ 
     jsrcs += list(filter(lambda x: x.endswith('.jsrc'), peers))
     peers = list(filter(lambda x: not x.endswith('.jsrc'), peers))
 
-    sources_dir = 'src'
-    mkdir_p(sources_dir)
-    for s in jsrcs:
-        if s.endswith('.jsrc'):
-            with contextlib.closing(tarfile.open(s, 'r')) as tf:
-                tf.extractall(sources_dir)
-
-    srcs = []
-    for r, _, files in os.walk(sources_dir):
-        for f in files:
-            srcs.append(os.path.join(r, f))
+    sources_dir = 'src' 
+    mkdir_p(sources_dir) 
+    for s in jsrcs: 
+        if s.endswith('.jsrc'): 
+            with contextlib.closing(tarfile.open(s, 'r')) as tf: 
+                tf.extractall(sources_dir) 
+ 
+    srcs = [] 
+    for r, _, files in os.walk(sources_dir): 
+        for f in files: 
+            srcs.append(os.path.join(r, f)) 
     srcs += jsrcs
     srcs = list(filter(lambda x: x.endswith('.java'), srcs))
-
-    classes_dir = 'cls'
-    mkdir_p(classes_dir)
+ 
+    classes_dir = 'cls' 
+    mkdir_p(classes_dir) 
     classpath = os.pathsep.join(peers)
-
-    if srcs:
+ 
+    if srcs: 
         temp_sources_file = 'temp.sources.list'
         with open(temp_sources_file, 'w') as ts:
             ts.write(' '.join(srcs))
         sp.check_call([opts.javac_bin, '-nowarn', '-g', '-classpath', classpath, '-encoding', 'UTF-8', '-d', classes_dir] + javac_opts + ['@' + temp_sources_file])
-
-    for s in jsrcs:
-        if s.endswith('-sources.jar'):
-            with zipfile.ZipFile(s) as zf:
-                zf.extractall(sources_dir)
-
-        elif s.endswith('.jar'):
-            with zipfile.ZipFile(s) as zf:
-                zf.extractall(classes_dir)
-
+ 
+    for s in jsrcs: 
+        if s.endswith('-sources.jar'): 
+            with zipfile.ZipFile(s) as zf: 
+                zf.extractall(sources_dir) 
+ 
+        elif s.endswith('.jar'): 
+            with zipfile.ZipFile(s) as zf: 
+                zf.extractall(classes_dir) 
+ 
     if opts.vcs_mf:
         sp.check_call([opts.jar_bin, 'cfm', opts.jar_output, opts.vcs_mf, os.curdir], cwd=classes_dir)
     else:
         sp.check_call([opts.jar_bin, 'cfM', opts.jar_output, os.curdir], cwd=classes_dir)
-
-    if opts.srcs_jar_output:
-        for s in jsrcs:
-            if s.endswith('.java'):
-                if opts.package_prefix:
-                    d = os.path.join(sources_dir, *(opts.package_prefix.split('.') + [os.path.basename(s)]))
-
-                else:
-                    d = os.path.join(sources_dir, os.path.basename(s))
-
-                shutil.copyfile(s, d)
-
+ 
+    if opts.srcs_jar_output: 
+        for s in jsrcs: 
+            if s.endswith('.java'): 
+                if opts.package_prefix: 
+                    d = os.path.join(sources_dir, *(opts.package_prefix.split('.') + [os.path.basename(s)])) 
+ 
+                else: 
+                    d = os.path.join(sources_dir, os.path.basename(s)) 
+ 
+                shutil.copyfile(s, d) 
+ 
         if opts.vcs_mf:
             sp.check_call([opts.jar_bin, 'cfm', opts.srcs_jar_output, opts.vcs_mf, os.curdir], cwd=sources_dir)
         else:
             sp.check_call([opts.jar_bin, 'cfM', opts.srcs_jar_output, os.curdir], cwd=sources_dir)
-
-
-if __name__ == '__main__':
-    main()
+ 
+ 
+if __name__ == '__main__': 
+    main() 

+ 50 - 50
build/scripts/copy_to_dir.py

@@ -2,19 +2,19 @@ import errno
 import sys
 import os
 import shutil
-import optparse
-import tarfile
+import optparse 
+import tarfile 
 
 
-def parse_args():
-    parser = optparse.OptionParser()
-    parser.add_option('--build-root')
-    parser.add_option('--dest-dir')
-    parser.add_option('--dest-arch')
-    return parser.parse_args()
-
-
-def ensure_dir_exists(path):
+def parse_args(): 
+    parser = optparse.OptionParser() 
+    parser.add_option('--build-root') 
+    parser.add_option('--dest-dir') 
+    parser.add_option('--dest-arch') 
+    return parser.parse_args() 
+ 
+ 
+def ensure_dir_exists(path): 
     try:
         os.makedirs(path)
     except OSError as e:
@@ -24,52 +24,52 @@ def ensure_dir_exists(path):
             raise
 
 
-def hardlink_or_copy(src, dst):
-    if os.name == 'nt':
-        shutil.copy(src, dst)
-    else:
-        try:
-            os.link(src, dst)
-        except OSError as e:
-            if e.errno == errno.EEXIST:
-                return
-            elif e.errno == errno.EXDEV:
+def hardlink_or_copy(src, dst): 
+    if os.name == 'nt': 
+        shutil.copy(src, dst) 
+    else: 
+        try: 
+            os.link(src, dst) 
+        except OSError as e: 
+            if e.errno == errno.EEXIST: 
+                return 
+            elif e.errno == errno.EXDEV: 
                 sys.stderr.write("Can't make cross-device hardlink - fallback to copy: {} -> {}\n".format(src, dst))
-                shutil.copy(src, dst)
-            else:
-                raise
-
-
+                shutil.copy(src, dst) 
+            else: 
+                raise 
+ 
+ 
 def main():
-    opts, args = parse_args()
-    assert opts.build_root
-    assert opts.dest_dir
-
-    dest_arch = None
-    if opts.dest_arch:
-        if opts.dest_arch.endswith('.tar'):
+    opts, args = parse_args() 
+    assert opts.build_root 
+    assert opts.dest_dir 
+ 
+    dest_arch = None 
+    if opts.dest_arch: 
+        if opts.dest_arch.endswith('.tar'): 
             dest_arch = tarfile.open(opts.dest_arch, 'w', dereference=True)
-        elif opts.dest_arch.endswith('.tar.gz') or opts.dest_arch.endswith('.tgz'):
+        elif opts.dest_arch.endswith('.tar.gz') or opts.dest_arch.endswith('.tgz'): 
             dest_arch = tarfile.open(opts.dest_arch, 'w:gz', dereference=True)
-        else:
-            # TODO: move check to graph generation stage
-            raise Exception('Unsopported archive type for {}. Use one of: tar, tar.gz, tgz.'.format(os.path.basename(opts.dest_arch)))
-
-    for arg in args:
+        else: 
+            # TODO: move check to graph generation stage 
+            raise Exception('Unsopported archive type for {}. Use one of: tar, tar.gz, tgz.'.format(os.path.basename(opts.dest_arch))) 
+ 
+    for arg in args: 
         dst = arg
-        if dst.startswith(opts.build_root):
-            dst = dst[len(opts.build_root) + 1:]
+        if dst.startswith(opts.build_root): 
+            dst = dst[len(opts.build_root) + 1:] 
 
         if dest_arch and not arg.endswith('.pkg.fake'):
-            dest_arch.add(arg, arcname=dst)
-
-        dst = os.path.join(opts.dest_dir, dst)
-        ensure_dir_exists(os.path.dirname(dst))
-        hardlink_or_copy(arg, dst)
-
-    if dest_arch:
-        dest_arch.close()
-
+            dest_arch.add(arg, arcname=dst) 
 
+        dst = os.path.join(opts.dest_dir, dst) 
+        ensure_dir_exists(os.path.dirname(dst)) 
+        hardlink_or_copy(arg, dst) 
+ 
+    if dest_arch: 
+        dest_arch.close() 
+ 
+ 
 if __name__ == '__main__':
     sys.exit(main())

+ 42 - 42
build/scripts/create_jcoverage_report.py

@@ -1,8 +1,8 @@
 import argparse
 import tarfile
-import zipfile
+import zipfile 
 import os
-import sys
+import sys 
 import time
 import subprocess
 
@@ -26,66 +26,66 @@ class Timer(object):
 
 def main(source, output, java, prefix_filter, exclude_filter, jars_list, output_format, tar_output, agent_disposition, runners_paths):
     timer = Timer()
-    reports_dir = 'jacoco_reports_dir'
-    mkdir_p(reports_dir)
-    with tarfile.open(source) as tf:
-        tf.extractall(reports_dir)
+    reports_dir = 'jacoco_reports_dir' 
+    mkdir_p(reports_dir) 
+    with tarfile.open(source) as tf: 
+        tf.extractall(reports_dir) 
     timer.step("Coverage data extracted")
-    reports = [os.path.join(reports_dir, fname) for fname in os.listdir(reports_dir)]
-
-    with open(jars_list) as f:
-        jars = f.read().strip().split()
+    reports = [os.path.join(reports_dir, fname) for fname in os.listdir(reports_dir)] 
+ 
+    with open(jars_list) as f: 
+        jars = f.read().strip().split() 
     if jars and runners_paths:
         for r in runners_paths:
             try:
                 jars.remove(r)
             except ValueError:
                 pass
-
-    src_dir = 'sources_dir'
-    cls_dir = 'classes_dir'
-
-    mkdir_p(src_dir)
-    mkdir_p(cls_dir)
-
-    for jar in jars:
-        if jar.endswith('devtools-jacoco-agent.jar'):
-            agent_disposition = jar
-
+ 
+    src_dir = 'sources_dir' 
+    cls_dir = 'classes_dir' 
+ 
+    mkdir_p(src_dir) 
+    mkdir_p(cls_dir) 
+ 
+    for jar in jars: 
+        if jar.endswith('devtools-jacoco-agent.jar'): 
+            agent_disposition = jar 
+ 
         # Skip java contrib - it's irrelevant coverage
         if jar.startswith('contrib/java'):
             continue
 
-        with zipfile.ZipFile(jar) as jf:
-            for entry in jf.infolist():
-                if entry.filename.endswith('.java'):
-                    dest = src_dir
-
-                elif entry.filename.endswith('.class'):
-                    dest = cls_dir
-
-                else:
-                    continue
-
+        with zipfile.ZipFile(jar) as jf: 
+            for entry in jf.infolist(): 
+                if entry.filename.endswith('.java'): 
+                    dest = src_dir 
+ 
+                elif entry.filename.endswith('.class'): 
+                    dest = cls_dir 
+ 
+                else: 
+                    continue 
+ 
                 entry.filename = entry.filename.encode('utf-8')
-                jf.extract(entry, dest)
+                jf.extract(entry, dest) 
     timer.step("Jar files extracted")
-
-    if not agent_disposition:
-        print>>sys.stderr, 'Can\'t find jacoco agent. Will not generate html report for java coverage.'
-
+ 
+    if not agent_disposition: 
+        print>>sys.stderr, 'Can\'t find jacoco agent. Will not generate html report for java coverage.' 
+ 
     if tar_output:
         report_dir = 'java.report.temp'
     else:
         report_dir = output
     mkdir_p(report_dir)
 
-    if agent_disposition:
+    if agent_disposition: 
         agent_cmd = [java, '-jar', agent_disposition, src_dir, cls_dir, prefix_filter or '.', exclude_filter or '__no_exclude__', report_dir, output_format]
-        agent_cmd += reports
-        subprocess.check_call(agent_cmd)
+        agent_cmd += reports 
+        subprocess.check_call(agent_cmd) 
         timer.step("Jacoco finished")
-
+ 
     if tar_output:
         with tarfile.open(output, 'w') as outf:
             outf.add(report_dir, arcname='.')
@@ -103,7 +103,7 @@ if __name__ == '__main__':
     parser.add_argument('--java', action='store')
     parser.add_argument('--prefix-filter', action='store')
     parser.add_argument('--exclude-filter', action='store')
-    parser.add_argument('--jars-list', action='store')
+    parser.add_argument('--jars-list', action='store') 
     parser.add_argument('--output-format', action='store', default="html")
     parser.add_argument('--raw-output', dest='tar_output', action='store_false', default=True)
     parser.add_argument('--agent-disposition', action='store')

+ 3 - 3
build/scripts/fetch_from.py

@@ -321,15 +321,15 @@ def process(fetched_file, file_name, args, remove=True):
         hardlink_or_copy(fetched_file, args.copy_to)
         if not args.outputs:
             args.outputs = [args.copy_to]
-
+ 
     if args.rename_to:
         args.rename.append(fetched_file)
         if not args.outputs:
             args.outputs = [args.rename_to]
-
+ 
     if args.copy_to_dir:
         hardlink_or_copy(fetched_file, os.path.join(args.copy_to_dir, file_name))
-
+ 
     if args.untar_to:
         ensure_dir(args.untar_to)
         # Extract only requested files

+ 36 - 36
build/scripts/fetch_from_sandbox.py

@@ -18,19 +18,19 @@ MDS_PREFIX = 'http://storage-int.mds.yandex.net/get-sandbox/'
 TEMPORARY_ERROR_CODES = (429, 500, 503, 504)
 
 
-def parse_args():
+def parse_args(): 
     parser = argparse.ArgumentParser()
     fetch_from.add_common_arguments(parser)
     parser.add_argument('--resource-id', type=int, required=True)
     parser.add_argument('--custom-fetcher')
     parser.add_argument('--resource-file')
     return parser.parse_args()
-
-
-class ResourceInfoError(Exception):
-    pass
-
-
+ 
+ 
+class ResourceInfoError(Exception): 
+    pass 
+ 
+ 
 class UnsupportedProtocolException(Exception):
     pass
 
@@ -75,37 +75,37 @@ def download_by_skynet(resource_info, file_name):
 
 
 def _urlopen(url, data=None, headers=None):
-    n = 10
+    n = 10 
     tout = 30
     started = time.time()
     reqid = uuid.uuid4()
-
+ 
     request = urllib2.Request(url, data=data, headers=headers or {})
     request.add_header('X-Request-Timeout', str(tout))
     request.add_header('X-Request-Id', str(reqid))
     request.add_header('User-Agent', 'fetch_from_sandbox.py')
-    for i in xrange(n):
+    for i in xrange(n): 
         retry_after = i
-        try:
+        try: 
             request.add_header('X-Request-Duration', str(int(time.time() - started)))
             return urllib2.urlopen(request, timeout=tout).read()
-
-        except urllib2.HTTPError as e:
+ 
+        except urllib2.HTTPError as e: 
             logging.warning('failed to fetch URL %s with HTTP code %d: %s', url, e.code, e)
             retry_after = int(e.headers.get('Retry-After', str(retry_after)))
-
+ 
             if e.code not in TEMPORARY_ERROR_CODES:
-                raise
-
-        except Exception as e:
+                raise 
+ 
+        except Exception as e: 
             logging.warning('failed to fetch URL %s: %s', url, e)
-
-        if i + 1 == n:
-            raise e
-
+ 
+        if i + 1 == n: 
+            raise e 
+ 
         time.sleep(retry_after)
-
-
+ 
+ 
 def _query(url):
     return json.loads(_urlopen(url))
 
@@ -133,19 +133,19 @@ def fetch_via_script(script, resource_id):
 
 
 def fetch(resource_id, custom_fetcher):
-    try:
+    try: 
         resource_info = get_resource_info(resource_id, touch=True, no_links=True)
-    except Exception as e:
+    except Exception as e: 
         sys.stderr.write(
             "Failed to fetch resource {}: {}\n".format(resource_id, str(e))
         )
         raise
-
+ 
     if resource_info.get('state', 'DELETED') != 'READY':
         raise ResourceInfoError("Resource {} is not READY".format(resource_id))
 
-    logging.info('Resource %s info %s', str(resource_id), json.dumps(resource_info))
-
+    logging.info('Resource %s info %s', str(resource_id), json.dumps(resource_info)) 
+ 
     resource_file_name = os.path.basename(resource_info["file_name"])
     expected_md5 = resource_info.get('md5')
 
@@ -183,9 +183,9 @@ def fetch(resource_id, custom_fetcher):
         if mds_link is not None:
             yield lambda: fetch_from.fetch_url(mds_link, True, resource_file_name, expected_md5)
 
-    if resource_info.get('attributes', {}).get('ttl') != 'inf':
-        sys.stderr.write('WARNING: resource {} ttl is not "inf".\n'.format(resource_id))
-
+    if resource_info.get('attributes', {}).get('ttl') != 'inf': 
+        sys.stderr.write('WARNING: resource {} ttl is not "inf".\n'.format(resource_id)) 
+ 
     exc_info = None
     for i, action in enumerate(itertools.islice(iter_tries(), 0, 10)):
         try:
@@ -210,10 +210,10 @@ def fetch(resource_id, custom_fetcher):
             raise exc_info[0], exc_info[1], exc_info[2]
         else:
             raise Exception("No available protocol and/or server to fetch resource")
-
+ 
     return fetched_file, resource_info['file_name']
 
-
+ 
 def _get_resource_info_from_file(resource_file):
     if resource_file is None or not os.path.exists(resource_file):
         return None
@@ -242,7 +242,7 @@ def _get_resource_info_from_file(resource_file):
 
 def main(args):
     custom_fetcher = os.environ.get('YA_CUSTOM_FETCHER')
-
+ 
     resource_info = _get_resource_info_from_file(args.resource_file)
     if resource_info:
         fetched_file = args.resource_file
@@ -250,14 +250,14 @@ def main(args):
     else:
         # This code should be merged to ya and removed.
         fetched_file, file_name = fetch(args.resource_id, custom_fetcher)
-
+ 
     fetch_from.process(fetched_file, file_name, args, remove=not custom_fetcher and not resource_info)
 
 
 if __name__ == '__main__':
     args = parse_args()
     fetch_from.setup_logging(args, os.path.basename(__file__))
-
+ 
     try:
         main(args)
     except Exception as e:

Some files were not shown because too many files changed in this diff