From 72fabae402e8396ac13a001e26fce3a09dc37f4d Mon Sep 17 00:00:00 2001 From: Christoph Alt <christoph.alt@fau.de> Date: Fri, 3 Mar 2023 14:52:11 +0100 Subject: [PATCH] added some docstrings --- cbutil/cpu_frequency.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cbutil/cpu_frequency.py b/cbutil/cpu_frequency.py index fa639b3..2a628c0 100644 --- a/cbutil/cpu_frequency.py +++ b/cbutil/cpu_frequency.py @@ -44,6 +44,18 @@ def read_frequency_from_file(file_path: str) -> float: def run_command(command: str) -> str: + """ + Runs a shell command and returns its output. + + Args: + command: The shell command to run. + + Returns: + The output of the command as a string. + + Raises: + ValueError: If there is an error running the shell command. + """ try: result = subprocess.run( command, @@ -58,6 +70,19 @@ def run_command(command: str) -> str: def filter_output(pattern: str, output: str) -> str: + """ + Filters the output of a command using a regex pattern. + + Args: + pattern: The regex pattern to search for. + output: The output of the command as a string. + + Returns: + The first match for the regex pattern in the output. + + Raises: + LookupError: If no match is found for the regex pattern. + """ pattern = re.compile(pattern) match = pattern.search(output) if match: -- GitLab