From df2537dd6dfcb50e58679e49f77a13113c664d81 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 15:43:59 +0200 Subject: [PATCH 01/10] main/imports --- rwx/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rwx/__main__.py b/rwx/__main__.py index 519fb8e..ddeeba8 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -1,6 +1,8 @@ #! /usr/bin/env python3 from pathlib import Path + import fs + if __name__ == "__main__": file_path = Path(__file__).resolve() root_path = file_path.parent From d23bbdd7c91ca1ed463b95a7d597af755771dabe Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 18:02:49 +0200 Subject: [PATCH 02/10] entry point --- rwx/__main__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rwx/__main__.py b/rwx/__main__.py index ddeeba8..f6276e4 100755 --- a/rwx/__main__.py +++ b/rwx/__main__.py @@ -1,4 +1,7 @@ #! /usr/bin/env python3 + +"""Entry point.""" + from pathlib import Path import fs From 2648c2e6ba21172942e7503f2001f15a27f17f35 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:43:26 +0200 Subject: [PATCH 03/10] /.venv --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0800ae8..4909e08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ /tmp +/.venv /.vscode /dist From 7d0ffb8a656260c229607d3df197344293ab3630 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:45:30 +0200 Subject: [PATCH 04/10] ruff/lint --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ccd0aa1..a9f4af7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,5 +31,6 @@ requires-python = ">= 3.10" [tool.hatch.version] path = "rwx/__init__.py" -[tool.ruff] +[tool.ruff.lint] +ignore = ["COM812", "D203", "D213", "ISC001"] select = ["ALL"] From 0a035f2cd67855ccffb83bbd3ebf0a14a1cac52c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:46:34 +0200 Subject: [PATCH 05/10] ruff/format --- rwx/__init__.py | 1 + rwx/cmd/squashfs/__init__.py | 18 +++++++++++------- rwx/grub/__init__.py | 9 +++++++-- rwx/log/__init__.py | 4 ++++ rwx/prj/sphinx.py | 18 ++++++++++++------ 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index a721b9a..a1c5ee6 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -1,2 +1,3 @@ """Read Write eXecute.""" + __version__ = "0.0.1" diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 343461e..322186c 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -6,10 +6,14 @@ rwx.cmd.need("mksquashfs") def mksquashfs(input_root: str, output_file: str): - ps.run([ - "mksquashfs", - input_root, - output_file, - "-comp", "zstd", - "-Xcompression-level", str(18), - ]) + ps.run( + [ + "mksquashfs", + input_root, + output_file, + "-comp", + "zstd", + "-Xcompression-level", + str(18), + ] + ) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 57e313c..2b44e57 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -17,8 +17,13 @@ MODULES = { } -def make_image(image_format: str, image_path: str, modules: list[str], - memdisk_path: str, pubkey_path: str | None = None) -> None: +def make_image( + image_format: str, + image_path: str, + modules: list[str], + memdisk_path: str, + pubkey_path: str | None = None, +) -> None: args = [ ("grub-mkimage",), ("--compress", COMPRESSION), diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 3502ab5..fcf01aa 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -16,6 +16,8 @@ def get_file_logger(name: str) -> logging.Logger: logger.setLevel(logging.INFO) # return logger + + def get_stream_logger() -> logging.Logger: out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setLevel(logging.INFO) @@ -25,4 +27,6 @@ def get_stream_logger() -> logging.Logger: logger.setLevel(logging.INFO) # return logger + + stream = get_stream_logger() diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index ccb8d0f..b09d8ee 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -15,12 +15,18 @@ class SphinxProject(Project): wipe(output_root) arguments: list[str] = [ "-E", - "-j", "2", - "-b", "html", - "-D", f"project={self.name}", - "-D", "master_doc={}".format("index"), - "-D", "html_theme={}".format("sphinx_rtd_theme"), - "-c", self.root, + "-j", + "2", + "-b", + "html", + "-D", + f"project={self.name}", + "-D", + "master_doc={}".format("index"), + "-D", + "html_theme={}".format("sphinx_rtd_theme"), + "-c", + self.root, # "-C", path.join(self.root, self.name), path.join(output_root, self.name), From 73dc9598b78436df12ff069da1063a285be412d4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:48:37 +0200 Subject: [PATCH 06/10] useless --- rwx/grub/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index 2b44e57..cd016ab 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -34,6 +34,6 @@ def make_image( if pubkey_path: args.append(("--pubkey", pubkey_path)) args.extend(modules) - if modules := MODULES.get(image_format, None): + if modules := MODULES.get(image_format): args.extend(modules) ps.run(*args) From 959107c245f3ede7ea0f728d7c6af6ae028cecaf Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:52:55 +0200 Subject: [PATCH 07/10] run/check --- rwx/ps/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 5b50456..6471fff 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -14,7 +14,7 @@ def get_tuples_args(tuples) -> list[str]: def run(*tuples) -> subprocess.CompletedProcess: - return subprocess.run(get_tuples_args(tuples), capture_output=False) + return subprocess.run(get_tuples_args(tuples), capture_output=False, check=True) def run_line(*tuples, charset: str = txt.CHARSET) -> str: @@ -23,6 +23,6 @@ def run_line(*tuples, charset: str = txt.CHARSET) -> str: def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: - process = subprocess.run(get_tuples_args(tuples), capture_output=True) + process = subprocess.run(get_tuples_args(tuples), capture_output=True, check=True) string = process.stdout.decode(charset) return string.rstrip().splitlines() From 4414a9a7120c1a9c4a5af211c082b181c65696b6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:54:59 +0200 Subject: [PATCH 08/10] ruff/line-length --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index a9f4af7..66a3933 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,9 @@ requires-python = ">= 3.10" [tool.hatch.version] path = "rwx/__init__.py" +[tool.ruff] +line-length = 80 + [tool.ruff.lint] ignore = ["COM812", "D203", "D213", "ISC001"] select = ["ALL"] From 3ce03d17c14161fb04c53fb0cae89b256db8debc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 12 Jun 2024 14:55:37 +0200 Subject: [PATCH 09/10] fix --- rwx/ps/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 6471fff..b66c21b 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -14,7 +14,9 @@ def get_tuples_args(tuples) -> list[str]: def run(*tuples) -> subprocess.CompletedProcess: - return subprocess.run(get_tuples_args(tuples), capture_output=False, check=True) + return subprocess.run( + get_tuples_args(tuples), capture_output=False, check=True + ) def run_line(*tuples, charset: str = txt.CHARSET) -> str: @@ -23,6 +25,8 @@ def run_line(*tuples, charset: str = txt.CHARSET) -> str: def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: - process = subprocess.run(get_tuples_args(tuples), capture_output=True, check=True) + process = subprocess.run( + get_tuples_args(tuples), capture_output=True, check=True + ) string = process.stdout.decode(charset) return string.rstrip().splitlines() From 282e2ac7a1490bcdf748d6c66580c555f584bc0b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 13 Jun 2024 10:16:53 +0200 Subject: [PATCH 10/10] log/level --- rwx/log/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index fcf01aa..50048e5 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -18,15 +18,15 @@ def get_file_logger(name: str) -> logging.Logger: return logger -def get_stream_logger() -> logging.Logger: +def get_stream_logger(level: int) -> logging.Logger: out_handler = logging.StreamHandler(stream=sys.stdout) - out_handler.setLevel(logging.INFO) + out_handler.setLevel(level) # logger = logging.getLogger() logger.addHandler(out_handler) - logger.setLevel(logging.INFO) + logger.setLevel(level) # return logger -stream = get_stream_logger() +stream = get_stream_logger(logging.INFO)