Browse Source

`build/plugins` ya style --py

iaz1607 1 year ago
parent
commit
f2bebe45e1

+ 1 - 1
build/plugins/_xsyn_includes.py

@@ -14,7 +14,7 @@ def get_include_callback():
         res = []
         if element.nodeType == element.ELEMENT_NODE and element.nodeName == "parse:include":
             attrs = element.attributes
-            for i in xrange(attrs.length):
+            for i in range(attrs.length):
                 attr = attrs.item(i)
                 if attr.nodeName == "path":
                     include_filename = attr.nodeValue

+ 0 - 2
build/plugins/create_init_py.py

@@ -1,7 +1,5 @@
 import os
 
-from _common import sort_by_keywords
-
 
 def oncreate_init_py_structure(unit, *args):
     if unit.get('DISTBUILD') or unit.get('AUTOCHECK'):

+ 3 - 1
build/plugins/docs.py

@@ -51,4 +51,6 @@ def onprocess_docs(unit, *args):
 def onprocess_mkdocs(unit, *args):
     variables = get_variables(unit)
     if variables:
-        unit.set(['_DOCS_VARS_FLAG', ' '.join(['--var {}={}'.format(k, v) for k, v in sorted(six.iteritems(variables))])])
+        unit.set(
+            ['_DOCS_VARS_FLAG', ' '.join(['--var {}={}'.format(k, v) for k, v in sorted(six.iteritems(variables))])]
+        )

+ 0 - 1
build/plugins/ios_app_settings.py

@@ -1,6 +1,5 @@
 import _common as common
 import ymake
-import os
 
 
 def onios_app_settings(unit, *args):

+ 18 - 11
build/plugins/java.py

@@ -18,9 +18,12 @@ def extract_macro_calls(unit, macro_value_name, macro_calls_delim):
     if not unit.get(macro_value_name):
         return []
 
-    return list(filter(
-        None, map(split_args, unit.get(macro_value_name).replace('$' + macro_value_name, '').split(macro_calls_delim))
-    ))
+    return list(
+        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):
@@ -69,7 +72,9 @@ def on_run_jbuild_program(unit, *args):
         args += ['FAKE_OUT', fake_out]
 
     prev = unit.get(['RUN_JAVA_PROGRAM_VALUE']) or ''
-    new_val = (prev + ' ' + six.ensure_str(base64.b64encode(six.ensure_binary(json.dumps(list(args)), encoding='utf-8')))).strip()
+    new_val = (
+        prev + ' ' + six.ensure_str(base64.b64encode(six.ensure_binary(json.dumps(list(args)), encoding='utf-8')))
+    ).strip()
     unit.set(['RUN_JAVA_PROGRAM_VALUE', new_val])
 
 
@@ -83,7 +88,9 @@ def ongenerate_script(unit, *args):
     if len(kv.get('TEMPLATE', [])) > len(kv.get('OUT', [])):
         ymake.report_configure_error('To many arguments for TEMPLATE parameter')
     prev = unit.get(['GENERATE_SCRIPT_VALUE']) or ''
-    new_val = (prev + ' ' + six.ensure_str(base64.b64encode(six.ensure_binary(json.dumps(list(args)), encoding='utf-8')))).strip()
+    new_val = (
+        prev + ' ' + six.ensure_str(base64.b64encode(six.ensure_binary(json.dumps(list(args)), encoding='utf-8')))
+    ).strip()
     unit.set(['GENERATE_SCRIPT_VALUE', new_val])
 
 
@@ -138,7 +145,7 @@ def onjava_module(unit, *args):
         '18',
         '19',
         '20',
-        '21'
+        '21',
     ):
         data['ENABLE_PREVIEW'] = extract_macro_calls(unit, 'ENABLE_PREVIEW_VALUE', args_delim)
 
@@ -208,7 +215,6 @@ def onjava_module(unit, *args):
         data['WITH_JDK'] = extract_macro_calls(unit, 'WITH_JDK_VALUE', args_delim)
 
     if not data['EXTERNAL_JAR']:
-        has_processor = extract_macro_calls(unit, 'GENERATE_VCS_JAVA_INFO_NODEP', args_delim)
         # IMPORTANT before switching vcs_info.py to python3 the value was always evaluated to $YMAKE_PYTHON but no
         # code in java dart parser extracts its value only checks this key for existance.
         data['EMBED_VCS'] = [['yes']]
@@ -241,7 +247,7 @@ def onjava_module(unit, *args):
         if external:
             unit.onpeerdir(external)
 
-    data = {k:v for k, v in six.iteritems(data) if v}
+    data = {k: v for k, v in six.iteritems(data) if v}
 
     dart = 'JAVA_DART: ' + six.ensure_str(base64.b64encode(six.ensure_binary(json.dumps(data)))) + '\n' + DELIM + '\n'
     unit.set_property(['JAVA_DART_DATA', dart])
@@ -288,7 +294,7 @@ def on_check_java_srcdir(unit, *args):
     if 'SKIP_CHECK_SRCDIR' in args:
         return
     for arg in args:
-        if not '$' in arg:
+        if '$' not in arg:
             arc_srcdir = os.path.join(unit.get('MODDIR'), arg)
             abs_srcdir = unit.resolve(os.path.join("$S/", arc_srcdir))
             if not os.path.exists(abs_srcdir) or not os.path.isdir(abs_srcdir):
@@ -352,7 +358,7 @@ def extract_words(words, keys):
         if w in keys:
             k = w
         else:
-            if not k in kv:
+            if k not in kv:
                 kv[k] = []
             kv[k].append(w)
 
@@ -361,7 +367,7 @@ def extract_words(words, keys):
 
 def parse_words(words):
     kv = extract_words(words, {'OUT', 'TEMPLATE'})
-    if not 'TEMPLATE' in kv:
+    if 'TEMPLATE' not in kv:
         kv['TEMPLATE'] = ['template.tmpl']
     ws = []
     for item in ('OUT', 'TEMPLATE'):
@@ -438,6 +444,7 @@ def _maven_coords_for_project(unit, project_dir):
     pom_path = unit.resolve(os.path.join('$S', project_dir, 'pom.xml'))
     if os.path.exists(pom_path):
         import xml.etree.ElementTree as et
+
         with open(pom_path, 'rb') as f:
             root = et.fromstring(f.read())
         for xpath in ('./{http://maven.apache.org/POM/4.0.0}artifactId', './artifactId'):

+ 13 - 5
build/plugins/large_files.py

@@ -1,7 +1,7 @@
 import json
 import os
 import ymake
-from _common import strip_roots, resolve_common_const
+from _common import resolve_common_const
 
 PLACEHOLDER_EXT = "external"
 
@@ -35,7 +35,9 @@ def onlarge_files(unit, *args):
             external = "{}.{}".format(arg, PLACEHOLDER_EXT)
             rel_placeholder = resolve_common_const(unit.resolve_arc_path(external))
             if not rel_placeholder.startswith("$S"):
-                ymake.report_configure_error('LARGE_FILES: neither actual data nor placeholder is found for "{}"'.format(arg))
+                ymake.report_configure_error(
+                    'LARGE_FILES: neither actual data nor placeholder is found for "{}"'.format(arg)
+                )
                 return
             try:
                 abs_placeholder = unit.resolve(rel_placeholder)
@@ -43,8 +45,10 @@ def onlarge_files(unit, *args):
                     res_desc = json.load(f)
                     storage = res_desc["storage"]
                     res_id = res_desc["resource_id"]
-            except e:
-                ymake.report_configure_error('LARGE_FILES: error processing placeholder file "{}.": {}'.format(external, e))
+            except Exception as e:
+                ymake.report_configure_error(
+                    'LARGE_FILES: error processing placeholder file "{}.": {}'.format(external, e)
+                )
                 return
 
             from_cmd = ['FILE', '{}'.format(res_id), 'OUT_NOAUTO', arg, 'EXTERNAL_FILE', external]
@@ -55,4 +59,8 @@ def onlarge_files(unit, *args):
             if method:
                 method(from_cmd)
             else:
-                ymake.report_configure_error('LARGE_FILES: error processing placeholder file "{}.": unknown storage kind "{}"'.format(external, storage))
+                ymake.report_configure_error(
+                    'LARGE_FILES: error processing placeholder file "{}.": unknown storage kind "{}"'.format(
+                        external, storage
+                    )
+                )

+ 2 - 0
build/plugins/lib/proxy/ya.make

@@ -2,6 +2,8 @@ OWNER(g:ymake)
 
 PY23_LIBRARY()
 
+STYLE_PYTHON()
+
 PY_SRCS(
     _metric_resolvers.py=lib._metric_resolvers
 )

+ 0 - 2
build/plugins/lib/test_const/__init__.py

@@ -447,7 +447,6 @@ class Status(object):
 
 
 class _Colors(object):
-
     _NAMES = [
         "blue",
         "cyan",
@@ -480,7 +479,6 @@ Colors = _Colors()
 
 
 class _Highlight(object):
-
     _MARKERS = {
         # special
         "RESET": "rst",

+ 2 - 0
build/plugins/lib/test_const/proxy/ya.make

@@ -2,6 +2,8 @@ OWNER(g:ymake)
 
 PY23_LIBRARY()
 
+STYLE_PYTHON()
+
 PY_SRCS(
     __init__.py=lib.test_const
 )

+ 2 - 0
build/plugins/lib/test_const/ya.make

@@ -2,6 +2,8 @@ OWNER(g:ymake)
 
 PY23_LIBRARY()
 
+STYLE_PYTHON()
+
 PY_SRCS(
     __init__.py
 )

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