# Path: MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py
# class Node(object):
# 
#     """This class is very generic, and has 3 attributes:
# 
#         - children: as with any tree it needs to have children
# 
#         - limit: the maximum amount of children before castcading to the next level
# 
#         - rules: the class instances allowed to be children of this object
# 
# 
#         Optional inputs:
# 
#           limit: the maximum num of children the node can have. 0 for no limit.
# 
#           rules: list of class types this node can have as child objects.
# 
#         """
# 
#     def __init__(self, **kwargs):
#         self.children = []
#         '''list of child nodes belonging to this node'''
# 
#         if "limit" in kwargs:
#             self.limit = kwargs["limit"]
#             '''max number of children in list'''
#         else:
#             self.limit = 0
#         self.item = None
#         if "rules" in kwargs:
#             self.rules = kwargs["rules"]
#             '''list of types of nodes which are accepted as child nodes'''
#         else:
#             self.rules = []
# 
#     def PopAllChildren(self):
#         '''
#         Method to remove and return all children of current node
# 
#         :return: list of children
#         '''
#         indexes = self.GetChildrenIndexes()
#         children = []
#         for c in indexes:
#             child = self.PopChild(c)
#             children.append(child)
#         return children
# 
#     def GetChildrenIndexes(self):
#         '''
#         Method to get a list of indexes at which children reside at
# 
#         :return: list of indexes
#         '''
#         indexes = list(range(len(self.children)))
#         return indexes
# 
#     def SetItem(self, new_item):
#         self.item = new_item
# 
#     def ReplaceChild(self, key, item):
#         '''
#         Method to remove child at <key> and replace it with <item>, then put the child back onto the end of the list
# 
#         :param key: index to position <item>
# 
#         :param item: child object to add
# 
#         :return:
#         '''
#         if key in self.GetChildrenIndexes():
#             node = self.GetChild(key)
#             children = node.GetChildrenIndexes()
#             child_nodes = [(i, node.GetChild(i)) for i in children]
#             self.children[key] = item
#             [self.children[key].AddChild(kid[1], kid[0])
#              for kid in child_nodes]
# 
#     def GetItem(self):
#         return self.item
# 
#     def GetChild(self, index):
#         if index == -1:
#             index = len(self.children) - 1
#             if index == -1:
#                 return None
#         if index < len(self.children):
#             return self.children[index]
# 
#     def AddChild(self, item, index=-1):
#         """adds the child to the list - index is included as an optional param but doesn't do anything because
#         this allows us to ducktype between this and IndexedNode """
# 
#         self.children.append(item)
# 
#     def PopChild(self, key):
#         if key < len(self.children):
#             return self.children.pop(key)
# 
#     def AddRule(self, rule):
#         self.rules.append(rule)


from MuseParse.classes.ObjectHierarchy.TreeClasses.BaseTree import Node
        '''

        Method which converts the object instance and its attributes to a string of lilypond code

        :return: str of lilypond code
        '''
        lilystring = ""
        if self.item is not None:
            lstring = self.item.toLily()
            if isinstance(lstring, str):
                lilystring += lstring
            else:
                lilystring = lstring
        child = self.GetChild(0)
        if child is not None:
            if isinstance(lilystring, str):
                lilystring += child.toLily()
            else:
                lilystring.append(child.toLily())
        return lilystring


class DirectionNode(SelfNode):
    pass


class ExpressionNode(SelfNode):
    pass



# Path: MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py
# class Node(object):
# 
#     """This class is very generic, and has 3 attributes:
# 
#         - children: as with any tree it needs to have children
# 
#         - limit: the maximum amount of children before castcading to the next level
# 
#         - rules: the class instances allowed to be children of this object
# 
# 
#         Optional inputs:
# 
#           limit: the maximum num of children the node can have. 0 for no limit.
# 
#           rules: list of class types this node can have as child objects.
# 
#         """
# 
#     def __init__(self, **kwargs):
#         self.children = []
#         '''list of child nodes belonging to this node'''
# 
#         if "limit" in kwargs:
#             self.limit = kwargs["limit"]
#             '''max number of children in list'''
#         else:
#             self.limit = 0
#         self.item = None
#         if "rules" in kwargs:
#             self.rules = kwargs["rules"]
#             '''list of types of nodes which are accepted as child nodes'''
#         else:
#             self.rules = []
# 
#     def PopAllChildren(self):
#         '''
#         Method to remove and return all children of current node
# 
#         :return: list of children
#         '''
#         indexes = self.GetChildrenIndexes()
#         children = []
#         for c in indexes:
#             child = self.PopChild(c)
#             children.append(child)
#         return children
# 
#     def GetChildrenIndexes(self):
#         '''
#         Method to get a list of indexes at which children reside at
# 
#         :return: list of indexes
#         '''
#         indexes = list(range(len(self.children)))
#         return indexes
# 
#     def SetItem(self, new_item):
#         self.item = new_item
# 
#     def ReplaceChild(self, key, item):
#         '''
#         Method to remove child at <key> and replace it with <item>, then put the child back onto the end of the list
# 
#         :param key: index to position <item>
# 
#         :param item: child object to add
# 
#         :return:
#         '''
#         if key in self.GetChildrenIndexes():
#             node = self.GetChild(key)
#             children = node.GetChildrenIndexes()
#             child_nodes = [(i, node.GetChild(i)) for i in children]
#             self.children[key] = item
#             [self.children[key].AddChild(kid[1], kid[0])
#              for kid in child_nodes]
# 
#     def GetItem(self):
#         return self.item
# 
#     def GetChild(self, index):
#         if index == -1:
#             index = len(self.children) - 1
#             if index == -1:
#                 return None
#         if index < len(self.children):
#             return self.children[index]
# 
#     def AddChild(self, item, index=-1):
#         """adds the child to the list - index is included as an optional param but doesn't do anything because
#         this allows us to ducktype between this and IndexedNode """
# 
#         self.children.append(item)
# 
#     def PopChild(self, key):
#         if key < len(self.children):
#             return self.children.pop(key)
# 
#     def AddRule(self, rule):
#         self.rules.append(rule)


# Path: MuseParse/classes/ObjectHierarchy/TreeClasses/OtherNodes.py
from MuseParse.classes.ObjectHierarchy.TreeClasses.BaseTree import Node

        '''

        Method which converts the object instance and its attributes to a string of lilypond code

        :return: str of lilypond code
        '''
        lilystring = ""
        if self.item is not None:
            lstring = self.item.toLily()
            if isinstance(lstring, str):
                lilystring += lstring
            else:
                lilystring = lstring
        child = self.GetChild(0)
        if child is not None:
            if isinstance(lilystring, str):
                lilystring += child.toLily()
            else:
                lilystring.append(child.toLily())
        return lilystring


class DirectionNode(SelfNode):
    pass


class ExpressionNode(SelfNode):
    pass



class KeyNode(Node):