Skip to content

Commit

Permalink
Fixed passing arguments to analyses
Browse files Browse the repository at this point in the history
  • Loading branch information
AryazE committed Mar 5, 2024
1 parent 38cb1e5 commit 8b3d771
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dynapyt/analyses/BaseAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class BaseAnalysis:

def __init__(self, conf: str = None) -> None:
def __init__(self, conf: str = None, output_dir: str = None) -> None:
self.asts = {}
self.conf = conf

Expand Down
2 changes: 1 addition & 1 deletion src/dynapyt/run_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run_analysis(
else:
rmtree(output_dir)
output_dir.mkdir()
analyses = [f"{a};{str(output_dir)}" for a in analyses]
analyses = [f"{a};output_dir={str(output_dir)}" for a in analyses]
with open(str(analyses_file), "w") as f:
f.write("\n".join(analyses))

Expand Down
4 changes: 2 additions & 2 deletions src/dynapyt/utils/runtimeUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def load_analyses(analyses: List[Any]) -> List[BaseAnalysis]:
if ";" in ana:
parts = ana.split(";")
ana = parts[0]
conf = tuple(parts[1:])
conf = {p.split("=")[0]: p.split("=")[1] for p in parts[1:]}
module_parts = ana.split(".")
module = importlib.import_module(".".join(module_parts[:-1]))
class_ = getattr(module, module_parts[-1])
if conf is not None:
res_analyses.append(class_(*conf))
res_analyses.append(class_(**conf))
else:
res_analyses.append(class_())
elif isinstance(ana, BaseAnalysis):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_analysis/call_graph/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


class TestAnalysis(BaseAnalysis):
def __init__(self, conf: str = None):
super().__init__(conf)
def __init__(self, conf: str = None, **kwargs):
super().__init__(conf, **kwargs)
self.graph = {}

"""
Expand Down

0 comments on commit 8b3d771

Please sign in to comment.