From 12a2a82cfeb328468ed47620e7bba019df0bff39 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:27:04 +0200 Subject: [PATCH 1/4] lint/log --- rwx/log/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 50048e5..5470e67 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -3,29 +3,29 @@ import sys def get_file_logger(name: str) -> logging.Logger: + # formatter formatter = logging.Formatter( "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", ) - # + # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setFormatter(formatter) out_handler.setLevel(logging.INFO) - # + # logger logger = logging.getLogger(name) logger.addHandler(out_handler) logger.setLevel(logging.INFO) - # return logger def get_stream_logger(level: int) -> logging.Logger: + # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setLevel(level) - # + # logger logger = logging.getLogger() logger.addHandler(out_handler) logger.setLevel(level) - # return logger From 26632881275443890e02694934231523e874c336 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:36:29 +0200 Subject: [PATCH 2/4] lint/log --- rwx/log/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rwx/log/__init__.py b/rwx/log/__init__.py index 5470e67..12fb781 100644 --- a/rwx/log/__init__.py +++ b/rwx/log/__init__.py @@ -1,8 +1,11 @@ +"""Handle logging.""" + import logging import sys def get_file_logger(name: str) -> logging.Logger: + """Return a file logger.""" # formatter formatter = logging.Formatter( "%(name)s: %(asctime)s | %(levelname)s | %(filename)s:%(lineno)s | %(process)d >>> %(message)s", @@ -19,6 +22,7 @@ def get_file_logger(name: str) -> logging.Logger: def get_stream_logger(level: int) -> logging.Logger: + """Return a stream logger.""" # handler out_handler = logging.StreamHandler(stream=sys.stdout) out_handler.setLevel(level) From eb5a386e02e2ebfa19762b355cd7826090bde3e3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:45:07 +0200 Subject: [PATCH 3/4] lint/ps --- rwx/ps/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index b66c21b..b2eca55 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -1,9 +1,12 @@ +"""Handle processes.""" + import subprocess from rwx import txt -def get_tuples_args(tuples) -> list[str]: +def get_tuples_args(*tuples: tuple[str]) -> list[str]: + """Turn arguments tuples into an arguments list.""" args: list[str] = [] for item in tuples: if type(item) is tuple: @@ -13,18 +16,21 @@ def get_tuples_args(tuples) -> list[str]: return args -def run(*tuples) -> subprocess.CompletedProcess: +def run(*tuples: tuple[str]) -> subprocess.CompletedProcess: + """Run from a list of arguments tuples.""" return subprocess.run( get_tuples_args(tuples), capture_output=False, check=True ) -def run_line(*tuples, charset: str = txt.CHARSET) -> str: +def run_line(*tuples: tuple[str], charset: str = txt.CHARSET) -> str: + """Run and return output line.""" lines = run_lines(*get_tuples_args(tuples), charset=charset) return lines[0] -def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: +def run_lines(*tuples: tuple[str], charset: str = txt.CHARSET) -> list[str]: + """Run and return output lines.""" process = subprocess.run( get_tuples_args(tuples), capture_output=True, check=True ) From 8c896c9074f1a9b1f17f4ed56092d6d3fbd1c127 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 16:45:56 +0200 Subject: [PATCH 4/4] lint/txt --- rwx/txt/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rwx/txt/__init__.py b/rwx/txt/__init__.py index 369202c..be2f273 100644 --- a/rwx/txt/__init__.py +++ b/rwx/txt/__init__.py @@ -1 +1,3 @@ +"""Handle text.""" + CHARSET = "UTF-8"