Skip to content
Snippets Groups Projects
Commit 72fabae4 authored by Christoph Alt's avatar Christoph Alt
Browse files

added some docstrings

parent e50d7039
No related branches found
No related tags found
1 merge request!4Devel/frequency
Pipeline #51054 failed
...@@ -44,6 +44,18 @@ def read_frequency_from_file(file_path: str) -> float: ...@@ -44,6 +44,18 @@ def read_frequency_from_file(file_path: str) -> float:
def run_command(command: str) -> str: 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: try:
result = subprocess.run( result = subprocess.run(
command, command,
...@@ -58,6 +70,19 @@ def run_command(command: str) -> str: ...@@ -58,6 +70,19 @@ def run_command(command: str) -> str:
def filter_output(pattern: str, output: 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) pattern = re.compile(pattern)
match = pattern.search(output) match = pattern.search(output)
if match: if match:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment