# Path: lems/base/base.py
# class LEMSBase(object):
#     """
#     Base object for PyLEMS.
#     """
# 
#     def copy(self):
#         return copy.deepcopy(self)
# 
#     def toxml(self):
#         return ""
# 
# Path: lems/base/stack.py
# class Stack(LEMSBase):
#     """
#     Basic stack implementation.
#     """
# 
#     def __init__(self):
#         """
#         Constructor.
#         """
# 
#         self.stack = []
#         """ List used to store the stack contents.
#         :type: list """
# 
#     def push(self, val):
#         """
#         Pushed a value onto the stack.
# 
#         :param val: Value to be pushed.
#         :type val: *
#         """
# 
#         self.stack = [val] + self.stack
# 
#     def pop(self):
#         """
#         Pops a value off the top of the stack.
# 
#         :return: Value popped off the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             val = self.stack[0]
#             self.stack = self.stack[1:]
#             return val
#         else:
#             raise StackError("Stack empty")
# 
#     def top(self):
#         """
#         Returns the value off the top of the stack without popping.
# 
#         :return: Value on the top of the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             return self.stack[0]
#         else:
#             raise StackError("Stack empty")
# 
#     def is_empty(self):
#         """
#         Checks if the stack is empty.
# 
#         :return: True if the stack is empty, otherwise False.
#         :rtype: Boolean
#         """
# 
#         return self.stack == []
# 
#     def __str__(self):
#         """
#         Returns a string representation of the stack.
# 
#         @note: This assumes that the stack contents are capable of generating
#         string representations.
#         """
# 
#         if len(self.stack) == 0:
#             s = "[]"
#         else:
#             s = "[" + str(self.stack[0])
#             for i in range(1, len(self.stack)):
#                 s += ", " + str(self.stack[i])
#             s += "]"
#         return s
# 
#     def __repr__(self):
#         return self.__str__()
# 
# Path: lems/base/errors.py
# class SimBuildError(LEMSError):
#     """
#     Exception class to signal errors in building the simulation.
#     """
# 
#     pass
# 
# Path: lems/sim/recording.py
# class Recording(LEMSBase):
#     """
#     Stores details of a variable recording across a single simulation run.
#     """
# 
#     def __init__(self, variable, full_path, data_output, recorder):
#         self.variable = variable
# 
#         self.full_path = full_path
# 
#         self.data_output = data_output
# 
#         self.recorder = recorder
# 
#         self.values = []
# 
#     def __str__(self):
#         return "Recording: {0} ({1}), {2}, size: {3}".format(
#             self.variable, self.full_path, self.recorder, len(self.values)
#         )
# 
#     def __repr__(self):
#         return self.__str__()
# 
#     def add_value(self, time, value):
#         self.values.append((time, value))


from lems.base.base import LEMSBase
from lems.base.stack import Stack
from lems.base.errors import SimBuildError
from lems.sim.recording import Recording
from math import *
import ast
import sys
            else:
                idx = -1

            if child in self.children:
                childobj = self.children[child]
                if idx != -1:
                    childobj = childobj.array[idx]
            elif child in self.component.parameters:
                ctx = self.component
                p = ctx.parameters[child]
                return self.resolve_path("../" + p.value)
            elif child in self.__dict__.keys():
                child_resolved = self.__dict__[child]
                # print("Think it's a link from %s to %s"%(child, child_resolved))
                return self.resolve_path("../" + child_resolved)
            else:
                if self.debug:
                    keys = list(self.__dict__.keys())
                    keys.sort()
                    prefix = "--- "
                    print("{0}    Keys for {1}".format(prefix, self.id))
                    for k in keys:
                        key_str = str(self.__dict__[k])
                        if (
                            len(key_str) > 0
                            and not key_str == "[]"
                            and not key_str == "{}"
                        ):
                            print("{0}       {1} -> {2}".format(prefix, k, key_str))


# Path: lems/base/base.py
# class LEMSBase(object):
#     """
#     Base object for PyLEMS.
#     """
# 
#     def copy(self):
#         return copy.deepcopy(self)
# 
#     def toxml(self):
#         return ""
# 
# Path: lems/base/stack.py
# class Stack(LEMSBase):
#     """
#     Basic stack implementation.
#     """
# 
#     def __init__(self):
#         """
#         Constructor.
#         """
# 
#         self.stack = []
#         """ List used to store the stack contents.
#         :type: list """
# 
#     def push(self, val):
#         """
#         Pushed a value onto the stack.
# 
#         :param val: Value to be pushed.
#         :type val: *
#         """
# 
#         self.stack = [val] + self.stack
# 
#     def pop(self):
#         """
#         Pops a value off the top of the stack.
# 
#         :return: Value popped off the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             val = self.stack[0]
#             self.stack = self.stack[1:]
#             return val
#         else:
#             raise StackError("Stack empty")
# 
#     def top(self):
#         """
#         Returns the value off the top of the stack without popping.
# 
#         :return: Value on the top of the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             return self.stack[0]
#         else:
#             raise StackError("Stack empty")
# 
#     def is_empty(self):
#         """
#         Checks if the stack is empty.
# 
#         :return: True if the stack is empty, otherwise False.
#         :rtype: Boolean
#         """
# 
#         return self.stack == []
# 
#     def __str__(self):
#         """
#         Returns a string representation of the stack.
# 
#         @note: This assumes that the stack contents are capable of generating
#         string representations.
#         """
# 
#         if len(self.stack) == 0:
#             s = "[]"
#         else:
#             s = "[" + str(self.stack[0])
#             for i in range(1, len(self.stack)):
#                 s += ", " + str(self.stack[i])
#             s += "]"
#         return s
# 
#     def __repr__(self):
#         return self.__str__()
# 
# Path: lems/base/errors.py
# class SimBuildError(LEMSError):
#     """
#     Exception class to signal errors in building the simulation.
#     """
# 
#     pass
# 
# Path: lems/sim/recording.py
# class Recording(LEMSBase):
#     """
#     Stores details of a variable recording across a single simulation run.
#     """
# 
#     def __init__(self, variable, full_path, data_output, recorder):
#         self.variable = variable
# 
#         self.full_path = full_path
# 
#         self.data_output = data_output
# 
#         self.recorder = recorder
# 
#         self.values = []
# 
#     def __str__(self):
#         return "Recording: {0} ({1}), {2}, size: {3}".format(
#             self.variable, self.full_path, self.recorder, len(self.values)
#         )
# 
#     def __repr__(self):
#         return self.__str__()
# 
#     def add_value(self, time, value):
#         self.values.append((time, value))


# Path: lems/sim/runnable.py
from lems.base.base import LEMSBase
from lems.base.stack import Stack
from lems.base.errors import SimBuildError
from lems.sim.recording import Recording
from math import *
import ast
import sys

            else:
                idx = -1

            if child in self.children:
                childobj = self.children[child]
                if idx != -1:
                    childobj = childobj.array[idx]
            elif child in self.component.parameters:
                ctx = self.component
                p = ctx.parameters[child]
                return self.resolve_path("../" + p.value)
            elif child in self.__dict__.keys():
                child_resolved = self.__dict__[child]
                # print("Think it's a link from %s to %s"%(child, child_resolved))
                return self.resolve_path("../" + child_resolved)
            else:
                if self.debug:
                    keys = list(self.__dict__.keys())
                    keys.sort()
                    prefix = "--- "
                    print("{0}    Keys for {1}".format(prefix, self.id))
                    for k in keys:
                        key_str = str(self.__dict__[k])
                        if (
                            len(key_str) > 0
                            and not key_str == "[]"
                            and not key_str == "{}"
                        ):
                            print("{0}       {1} -> {2}".format(prefix, k, key_str))


                raise SimBuildError(