copied from preCICE tutorials
This commit is contained in:
parent
46a7e98752
commit
3f1b1a6d0f
68 changed files with 156449 additions and 0 deletions
39
preCICE_tools/tests/systemtests/SystemtestArguments.py
Normal file
39
preCICE_tools/tests/systemtests/SystemtestArguments.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
from dataclasses import dataclass
|
||||
import yaml
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class SystemtestArguments:
|
||||
arguments: dict[str, str]
|
||||
|
||||
@classmethod
|
||||
def from_args(cls, cmd_args):
|
||||
if not cmd_args:
|
||||
return cls({})
|
||||
|
||||
params_provided = cmd_args.split(",")
|
||||
arguments = {}
|
||||
for param in params_provided:
|
||||
key, value = param.split(":")
|
||||
arguments[key] = value
|
||||
|
||||
return cls(arguments)
|
||||
|
||||
@classmethod
|
||||
def from_yaml(cls, yml_file):
|
||||
if not yml_file:
|
||||
return cls({})
|
||||
arguments = {}
|
||||
with open(yml_file, 'r') as f:
|
||||
arguments = yaml.safe_load(f)
|
||||
return cls(arguments)
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.arguments}"
|
||||
|
||||
def contains(self, argument_key):
|
||||
return argument_key in self.arguments.keys()
|
||||
|
||||
def get(self, argument_key) -> Optional[str]:
|
||||
return self.arguments[argument_key]
|
||||
Loading…
Add table
Add a link
Reference in a new issue