Modernize python and update pylint (#5096)
Update code to conform to the newer version of pylint available in
ubuntu-22.04, with few exceptions:
- disabled `import-outside-toplevel` for `main()` in
`jerry_client.py`
- disabled `consider-using-with` for the logfile of `TestSuite` in
`test262-harness.py` as using `with` is not practical in that case
Update test262-harness.py to use argparse instead of the now deprecated
optparse
Rename variables in jerry_client_main.py that redefined python builtins
or shadowed variables from an outer scope
Update python files to use f-stirngs
Add minimum python versions (3.6 and 3.8) to the CI jobs: without it the
default python version did not support the `with` statement for
`subprocess.Popen` used in `build.py` on macos, or in some cases f-stirngs
Remove `from __future__` imports that are no-ops in python 3
Remove shebang from non executable files
Re-enable most pylint checkers, except `missing-docstring`
JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
This commit is contained in:
+10
-10
@@ -57,7 +57,7 @@ def reduce_code(code):
|
||||
|
||||
|
||||
def js_to_native_code(path, name, build_type):
|
||||
with open(path, 'r') as js_source:
|
||||
with open(path, 'r', encoding='utf8') as js_source:
|
||||
code = js_source.read()
|
||||
|
||||
if build_type != 'debug':
|
||||
@@ -65,13 +65,13 @@ def js_to_native_code(path, name, build_type):
|
||||
|
||||
data = format_code(code, 1, 2)
|
||||
|
||||
native_code = """const static char {0}_n[] = "{0}";
|
||||
const static char {0}_s[] =
|
||||
native_code = f"""const static char {name}_n[] = "{name}";
|
||||
const static char {name}_s[] =
|
||||
{{
|
||||
{1}
|
||||
{data}
|
||||
}};
|
||||
const static int {0}_l = {2};
|
||||
""".format(name, data, len(code))
|
||||
const static int {name}_l = {len(code)};
|
||||
"""
|
||||
|
||||
return native_code
|
||||
|
||||
@@ -96,13 +96,13 @@ def main():
|
||||
|
||||
script_args = parser.parse_args()
|
||||
|
||||
gen_line = "/* This file is generated by %s. Please do not modify. */" % os.path.basename(__file__)
|
||||
gen_line = f"/* This file is generated by {os.path.basename(__file__)}. Please do not modify. */"
|
||||
|
||||
gen_output = [LICENSE, "", gen_line, "", HEADER]
|
||||
gen_structs = [NATIVE_STRUCT]
|
||||
|
||||
if script_args.main:
|
||||
gen_structs.append(' {{ {0}_n, {0}_s, {0}_l }}, \\'.format("main"))
|
||||
gen_structs.append(' { main_n, main_s, main_l }, \\')
|
||||
|
||||
files = glob.glob(os.path.join(script_args.js_source_path, '*.js'))
|
||||
|
||||
@@ -111,14 +111,14 @@ def main():
|
||||
name = extract_name(path)
|
||||
gen_output.append(js_to_native_code(path, name, script_args.build_type))
|
||||
if name != 'main':
|
||||
gen_structs.append(' {{ {0}_n, {0}_s, {0}_l }}, \\'.format(name))
|
||||
gen_structs.append(f' {{ {name}_n, {name}_s, {name}_l }}, \\')
|
||||
|
||||
gen_structs.append(' { NULL, NULL, 0 } \\\n};')
|
||||
|
||||
gen_output.append("\n".join(gen_structs))
|
||||
gen_output.append(FOOTER)
|
||||
|
||||
with open(os.path.join(script_args.output_path, 'jerry-targetjs.h'), 'w') as gen_file:
|
||||
with open(os.path.join(script_args.output_path, 'jerry-targetjs.h'), 'w', encoding='utf8') as gen_file:
|
||||
gen_file.write("\n".join(gen_output))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user