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

        :return: str of lilypond code

def toLily(self):
        '''
        Method which converts the object instance, its attributes and children to a string of lilypond code

        :return: str of lilypond code
        '''
        self.CheckDivisions()
        self.CheckTotals()
        staves = self.GetChildrenIndexes()
        name = ""
        shortname = ""
        if hasattr(self.item, "name"):
            name = self.item.name
            name = helpers.SplitString(name)
        if hasattr(self.item, "shortname"):
            shortname = helpers.SplitString(self.item.shortname)
        variables = self.CalculateVariable(str(self.index), staves)
        first_part = ""
        for staff, variable in zip(staves, variables):
            staffstring = variable
            if hasattr(
                    self.GetChild(staff),
                    "tab") and self.GetChild(staff).tab:
                staffstring += " = \\new TabStaff"
            elif hasattr(self.GetChild(staff), "drum") and self.GetChild(staff).drum:
                staffstring += " = \\drums"
            else:
                staffstring += " = \\new Staff"
            if len(staves) == 1:
                if name != "":
                    staffstring += " \with {\n"
                    staffstring += "instrumentName = " + name + " \n"
                    if shortname != "":
                        staffstring += "shortInstrumentName = " + \
                            shortname + " \n"
                    staffstring += " }"
            staffstring += "{" + self.GetChild(staff).toLily() + " }\n\n"
            first_part += staffstring

        second_part = ""
        if len(variables) > 1:
            second_part += "\\new StaffGroup "
            if name != "":
                second_part += "\with {\n"
                second_part += "instrumentName = " + name + " \n"
                second_part += " }"
            second_part += "<<"
        second_part += "\n".join(["\\" + var for var in variables])
        if len(variables) > 1:
            second_part += ">>"
        return [first_part, second_part]