2
0
forked from awendt/pyrelacs

adding comments

This commit is contained in:
wendtalexander 2024-09-29 18:27:27 +02:00
parent 13d4db25fa
commit bf8f3f5cb7

View File

@ -2,6 +2,7 @@ import sys
import importlib.util import importlib.util
import ast import ast
import pathlib import pathlib
from typing import Tuple
from IPython import embed from IPython import embed
import nixio as nix import nixio as nix
@ -11,12 +12,19 @@ log = config_logging()
class Repro: class Repro:
"""
Repro Class that searches in the repro folder for classes instances and executes the
the run function in the searched class
"""
def __init__(self) -> None: def __init__(self) -> None:
pass pass
def run_repro( def run_repro(
self, nix_file: nix.File, name: str, file: pathlib.Path, *args, **kwargs self, nix_file: nix.File, name: str, file: pathlib.Path, *args, **kwargs
) -> None: ) -> None:
spec = importlib.util.spec_from_file_location("rep", file) spec = importlib.util.spec_from_file_location("rep", file)
if not spec: if not spec:
log.error("Could not load the file") log.error("Could not load the file")
@ -33,7 +41,17 @@ class Repro:
else: else:
raise AttributeError(f"{file.name} has no {name} class") raise AttributeError(f"{file.name} has no {name} class")
def names_of_repros(self): def names_of_repros(self) -> Tuple[list, list]:
"""
Searches for class names in the repro folder in all python files
Returns
-------
Tuple[list, list]
list of class names
list of file names from the class names
"""
file_path_cur = pathlib.Path(__file__).parent file_path_cur = pathlib.Path(__file__).parent
python_files = list(file_path_cur.glob("**/*.py")) python_files = list(file_path_cur.glob("**/*.py"))
exclude_files = ["repros.py", "__init__.py"] exclude_files = ["repros.py", "__init__.py"]