diff --git a/lems/run.py b/lems/run.py index 1d2807f..2aaeb99 100644 --- a/lems/run.py +++ b/lems/run.py @@ -41,12 +41,25 @@ def process_args(): return parser.parse_args() -def main(): +def run(file_path,include_dirs=[],dlems=False,nogui=False): + """ + Function for running from a script or shell. + """ + import argparse + args = argparse.Namespace() + args.lems_file = file_path + args.I = include_dirs + args.dlems = dlems + args.nogui = nogui + main(args=args) + +def main(args=None): """ Program entry point. """ - args = process_args() + if args is None: + args = process_args() print('Parsing and resolving model: '+args.lems_file) model = Model() diff --git a/lems/sim/runnable.py b/lems/sim/runnable.py index f67d4a4..6f8dc1f 100644 --- a/lems/sim/runnable.py +++ b/lems/sim/runnable.py @@ -187,6 +187,9 @@ def add_child_to_group(self, group_name, child): #print sorted(self.__dict__.keys()) #print ".........." #print self.__dict__[group_name] + # Force group_name attribute to be a list before we append to it. + if type(self.__dict__[group_name]) is not list: + self.__dict__[group_name] = [self.__dict__[group_name]] self.__dict__[group_name].append(child) child.parent = self