diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-01-03 11:27:36 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-01-03 13:36:14 +0100 |
commit | 4f9967157d97d5f01bdee81e0b9d6a1e3ed9c27d (patch) | |
tree | 903d7f7a51c993a9ea2418f2c37a6572decfad3c | |
parent | applconfig: Changes for flake8 version 5.0.4 (diff) | |
download | rtems-central-4f9967157d97d5f01bdee81e0b9d6a1e3ed9c27d.tar.bz2 |
Changes for pylint 2.13.9
-rwxr-xr-x | generate_membench.py | 6 | ||||
-rwxr-xr-x | rtems_spec_to_x.py | 10 | ||||
-rw-r--r-- | rtemsspec/content.py | 2 | ||||
-rw-r--r-- | rtemsspec/glossary.py | 2 | ||||
-rw-r--r-- | rtemsspec/items.py | 6 | ||||
-rw-r--r-- | rtemsspec/sphinxcontent.py | 5 | ||||
-rw-r--r-- | rtemsspec/util.py | 4 | ||||
-rwxr-xr-x | spec2modules.py | 3 |
8 files changed, 21 insertions, 17 deletions
diff --git a/generate_membench.py b/generate_membench.py index 877c7d63..d0817dfc 100755 --- a/generate_membench.py +++ b/generate_membench.py @@ -748,7 +748,7 @@ def _generate_files() -> None: base = f"testsuites/membench/mem-{module}-{test.name}" source = f"{base}.c" build_spec = f"modules/rtems/spec/build/{base}.yml" - with open(build_spec, "w") as out: + with open(build_spec, "w", encoding="utf-8") as out: out.write(f"""SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause build-type: test-program cflags: [] @@ -771,7 +771,7 @@ use-before: [] """) req_spec = f"/{test.path}/req/mem-{test.name}" text = _text(f"{_TEXT} {test.topic}.") - with open(f"spec{req_spec}.yml", "w") as out: + with open(f"spec{req_spec}.yml", "w", encoding="utf-8") as out: out.write(f"""SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause copyrights: - Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de @@ -789,7 +789,7 @@ type: requirement val_spec = f"spec/{test.path}/val/mem-{test.name}.yml" brief = _text(f"{_TEST} {test.topic}.") test_suite_name = to_camel_case(f"Mem {test.name}") - with open(val_spec, "w") as out: + with open(val_spec, "w", encoding="utf-8") as out: out.write(f"""SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause copyrights: - Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) diff --git a/rtems_spec_to_x.py b/rtems_spec_to_x.py index 2e76b60b..f57dd406 100755 --- a/rtems_spec_to_x.py +++ b/rtems_spec_to_x.py @@ -40,7 +40,8 @@ def _run_pre_qualified_only_build(config: dict, item_cache: ItemCache) -> None: source_dir = config["source-directory"] workspace_dir = config["workspace-directory"] rtemsspec.util.copy_files(source_dir, workspace_dir, files) - with open(os.path.join(workspace_dir, "config.ini"), "w") as config_ini: + with open(os.path.join(workspace_dir, "config.ini"), "w", + encoding="utf-8") as config_ini: content = string.Template(config["config-ini"]).substitute(config) config_ini.write(content) specs = os.path.relpath(os.path.join(source_dir, "spec"), workspace_dir) @@ -53,7 +54,8 @@ def _run_pre_qualified_only_build(config: dict, item_cache: ItemCache) -> None: def _run_pre_qualified_doxygen(config: dict) -> None: workspace_dir = config["workspace-directory"] - with open(config["doxyfile-template"], "r") as doxyfile_template: + with open(config["doxyfile-template"], "r", + encoding="utf-8") as doxyfile_template: class Template(string.Template): """ Template class with custom delimiter. """ @@ -63,7 +65,9 @@ def _run_pre_qualified_doxygen(config: dict) -> None: doxyfile_vars["project_name"] = "RTEMS" doxyfile_vars["output_directory"] = "doc" content = Template(doxyfile_template.read()).substitute(doxyfile_vars) - with open(os.path.join(workspace_dir, "Doxyfile"), "w") as doxyfile: + with open(os.path.join(workspace_dir, "Doxyfile"), + "w", + encoding="utf-8") as doxyfile: doxyfile.write(content) rtemsspec.util.run_command(["doxygen"], workspace_dir) diff --git a/rtemsspec/content.py b/rtemsspec/content.py index eaab2873..c76d33d0 100644 --- a/rtemsspec/content.py +++ b/rtemsspec/content.py @@ -503,7 +503,7 @@ class Content: directory = os.path.dirname(path) if directory: os.makedirs(directory, exist_ok=True) - with open(path, "w+") as out: + with open(path, "w+", encoding="utf-8") as out: out.write(str(self)) diff --git a/rtemsspec/glossary.py b/rtemsspec/glossary.py index c2387e7b..df51acba 100644 --- a/rtemsspec/glossary.py +++ b/rtemsspec/glossary.py @@ -75,7 +75,7 @@ def _find_glossary_terms(path: str, document_terms: ItemMap, for src in glob.glob(path + "/**/*.rst", recursive=True): if src.endswith("glossary.rst"): continue - with open(src, "r") as out: + with open(src, "r", encoding="utf-8") as out: for term in _TERM.findall(out.read()): match = _TERM_2.search(term) if match: diff --git a/rtemsspec/items.py b/rtemsspec/items.py index 0aec25c7..2120a9ed 100644 --- a/rtemsspec/items.py +++ b/rtemsspec/items.py @@ -635,7 +635,7 @@ def _gather_spec_refinements(item: Item) -> Optional[_SpecType]: def _load_yaml_data(path: str, uid: str) -> Any: - with open(path, "r") as src: + with open(path, "r", encoding="utf-8") as src: try: data = yaml.safe_load(src.read()) except yaml.YAMLError as err: @@ -648,7 +648,7 @@ def _load_yaml_data(path: str, uid: str) -> Any: def _load_json_data(path: str, uid: str) -> Any: - with open(path, "r") as src: + with open(path, "r", encoding="utf-8") as src: try: data = json.load(src) except json.JSONDecodeError as err: @@ -788,7 +788,7 @@ class ItemCache: def save_data(self, path: str, data: Any) -> None: """ Saves the item data to the file specified by path. """ - with open(path, "w") as file: + with open(path, "w", encoding="utf-8") as file: data2 = {} for key, value in data.items(): if not key.startswith("_"): diff --git a/rtemsspec/sphinxcontent.py b/rtemsspec/sphinxcontent.py index 307bb837..1002f9ce 100644 --- a/rtemsspec/sphinxcontent.py +++ b/rtemsspec/sphinxcontent.py @@ -51,12 +51,11 @@ def get_label(name: str) -> str: def _simple_sep(maxi: Iterable[int]) -> str: - return " ".join(f"{'=' * val}" for val in maxi) + return " ".join(f"{'=' * width}" for width in maxi) def _simple_row(row: Iterable[str], maxi: Iterable[int]) -> str: - line = " ".join("{0:{width}}".format(cell, width=val) - for cell, val in zip(row, maxi)) + line = " ".join(f"{cell:{width}}" for cell, width in zip(row, maxi)) return line.rstrip() diff --git a/rtemsspec/util.py b/rtemsspec/util.py index ab9e90f6..59e3096c 100644 --- a/rtemsspec/util.py +++ b/rtemsspec/util.py @@ -58,13 +58,13 @@ def load_config(config_filename: str) -> Any: dirname = os.path.dirname(container) filename = os.path.join(dirname, self.construct_scalar(node)) IncludeLoader._filenames.insert(0, filename) - with open(filename, "r") as included_file: + with open(filename, "r", encoding="utf-8") as included_file: data = yaml.load(included_file, IncludeLoader) IncludeLoader._filenames.pop() return data IncludeLoader.add_constructor("!include", IncludeLoader.include) - with open(config_filename, "r") as config_file: + with open(config_filename, "r", encoding="utf-8") as config_file: return yaml.load(config_file.read(), Loader=IncludeLoader) diff --git a/spec2modules.py b/spec2modules.py index 4153fc53..4ae7a92d 100755 --- a/spec2modules.py +++ b/spec2modules.py @@ -36,7 +36,8 @@ def _diff(obj: rtemsspec.content.Content, path: str) -> None: from_file = f"a/{path}" to_file = f"b/{path}" try: - file_lines = open(path).read().splitlines() + with open(path, encoding="utf-8") as src: + file_lines = src.read().splitlines() except FileNotFoundError: file_lines = [] diff_lines = list( |