From 88311cb55c1af0df40e4d1ea1486b655bafd9fb6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:50:20 +0200 Subject: [PATCH 1/9] lint/prj --- rwx/prj/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index 227a686..6a3e059 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -1,8 +1,13 @@ +"""Handle projects.""" + from os import path class Project: + """Parent class for any type of project.""" + def __init__(self, file_path: str) -> None: + """Set file, root & name.""" self.file: str = path.realpath(file_path) self.root: str = path.dirname(self.file) self.name: str = path.basename(self.root) From f46d5a97656a4ed6bbfcf8c4a6d595fabcfba3ed Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:52:01 +0200 Subject: [PATCH 2/9] lint/grub --- rwx/grub/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rwx/grub/__init__.py b/rwx/grub/__init__.py index cd016ab..dde847a 100644 --- a/rwx/grub/__init__.py +++ b/rwx/grub/__init__.py @@ -1,3 +1,5 @@ +"""Wrap GRUB commands.""" + import cmd import ps @@ -24,6 +26,7 @@ def make_image( memdisk_path: str, pubkey_path: str | None = None, ) -> None: + """Make a binary bootable image.""" args = [ ("grub-mkimage",), ("--compress", COMPRESSION), From 9bb800381249b4b7d3f4fb165dd8131c4618f8bb Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:54:22 +0200 Subject: [PATCH 3/9] lint/sphinx --- rwx/prj/sphinx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index afa0901..13252f8 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -9,10 +9,14 @@ from rwx.prj import Project class SphinxProject(Project): + """Child class for a project based on Sphinx.""" + def __init__(self, file_path: str) -> None: + """Call the parent constructor.""" super().__init__(file_path) def build(self) -> None: + """Build the project.""" output_root: str = path.join(self.root, "out") wipe(output_root) arguments: list[str] = [ From ce3629a77601141735c9423246824bd3c3300fb4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:56:01 +0200 Subject: [PATCH 4/9] lint/deb --- rwx/deb/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rwx/deb/__init__.py b/rwx/deb/__init__.py index e9c6a9e..f022ca5 100644 --- a/rwx/deb/__init__.py +++ b/rwx/deb/__init__.py @@ -1,3 +1,5 @@ +"""Wrap Debian commands.""" + import cmd import ps @@ -8,7 +10,8 @@ BOOTSTRAP_ARCHITECTURE = "amd64" BOOTSTRAP_VARIANT = "minbase" -def bootstrap(root_path: str, suite: str, mirror_location: str): +def bootstrap(root_path: str, suite: str, mirror_location: str) -> None: + """Boostrap a base operating filesystem.""" command = [ ("debootstrap",), ("--arch", BOOTSTRAP_ARCHITECTURE), From f7c1d90dfdcd562ffb3f3b3459e237dc7040e0c9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:58:01 +0200 Subject: [PATCH 5/9] lint/squashfs --- rwx/cmd/squashfs/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rwx/cmd/squashfs/__init__.py b/rwx/cmd/squashfs/__init__.py index 322186c..85e20b2 100644 --- a/rwx/cmd/squashfs/__init__.py +++ b/rwx/cmd/squashfs/__init__.py @@ -1,3 +1,5 @@ +"""Wrap SquashFS commands.""" + import ps import rwx.cmd @@ -5,7 +7,8 @@ import rwx.cmd rwx.cmd.need("mksquashfs") -def mksquashfs(input_root: str, output_file: str): +def mksquashfs(input_root: str, output_file: str) -> None: + """Make a SquashFS bootable image file.""" ps.run( [ "mksquashfs", From 08b6364d9b8f1098983478731ade680b0cf7ace6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:00:39 +0200 Subject: [PATCH 6/9] lint/err --- rwx/err/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py index b996913..5df6b97 100644 --- a/rwx/err/__init__.py +++ b/rwx/err/__init__.py @@ -1,2 +1,4 @@ -class Exception(Exception): - pass +"""Handle errors.""" + +class Error(Exception): + """Parent class for all errors.""" From 3e0d5bf2bcd403d991fd149ab77ef1e6189bcfa4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:07:27 +0200 Subject: [PATCH 7/9] lint/fs --- rwx/fs/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index c91e0b8..9189778 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -23,7 +23,7 @@ def empty_file(path: str) -> None: def get_mount_uuid(path: str) -> str: - """Return the UUID of provided mountpoint path.""" + """Return the filesystem UUID of a mountpoint path.""" return ps.run_line( ("findmnt",), ("--noheadings",), @@ -32,7 +32,8 @@ def get_mount_uuid(path: str) -> str: ) -def get_path_mount(path: str): +def get_path_mount(path: str) -> str: + """Return the mountpoint path of an arbitrary path.""" return ps.run_line( ("stat",), ("--format", "%m"), @@ -40,11 +41,13 @@ def get_path_mount(path: str): ) -def get_path_uuid(path: str): +def get_path_uuid(path: str) -> str: + """Return the filesystem UUID of an arbitrary path.""" return get_mount_uuid(get_path_mount(path)) -def make_directory(path: str): +def make_directory(path: str) -> None: + """Make a directory (and its parents) from a path.""" os.makedirs(path, exist_ok=True) From aa1f06c20fc756227b18459c6d1883fd700df140 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:13:16 +0200 Subject: [PATCH 8/9] lint/fs --- rwx/fs/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 9189778..64a8483 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -56,15 +56,16 @@ def read_file(file_path: str): return file_object.read() -def read_file_lines(file_path: str, charset=CHARSET): +def read_file_lines(file_path: str, charset:str=CHARSET): return read_file_text(file_path).split(os.linesep) -def read_file_text(file_path: str, charset=CHARSET): +def read_file_text(file_path: str, charset:str=CHARSET): return read_file(file_path).decode(charset) -def wipe(path: str): +def wipe(path: str) -> None: + """Wipe provided path, whether directory or file.""" try: shutil.rmtree(path) except NotADirectoryError: @@ -73,6 +74,7 @@ def wipe(path: str): pass -def write(file_path: str, text: str, charset=CHARSET): +def write(file_path: str, text: str, charset:str=CHARSET) -> None: + """Write text into a file.""" with open(file_path, "bw") as file_object: file_object.write(text.encode(charset)) From 3393f0990742dda006ded747dae2e50319356af2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 17:13:37 +0200 Subject: [PATCH 9/9] format --- rwx/err/__init__.py | 1 + rwx/fs/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py index 5df6b97..294d8d8 100644 --- a/rwx/err/__init__.py +++ b/rwx/err/__init__.py @@ -1,4 +1,5 @@ """Handle errors.""" + class Error(Exception): """Parent class for all errors.""" diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index 64a8483..514fcec 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -56,11 +56,11 @@ def read_file(file_path: str): return file_object.read() -def read_file_lines(file_path: str, charset:str=CHARSET): +def read_file_lines(file_path: str, charset: str = CHARSET): return read_file_text(file_path).split(os.linesep) -def read_file_text(file_path: str, charset:str=CHARSET): +def read_file_text(file_path: str, charset: str = CHARSET): return read_file(file_path).decode(charset) @@ -74,7 +74,7 @@ def wipe(path: str) -> None: pass -def write(file_path: str, text: str, charset:str=CHARSET) -> None: +def write(file_path: str, text: str, charset: str = CHARSET) -> None: """Write text into a file.""" with open(file_path, "bw") as file_object: file_object.write(text.encode(charset))