Exemple #1
0
def Run(fname):
    parser = MxmlParser.MxmlParser()
    try:
        pieceObj = parser.parse(fname)
    except BaseException as e:
        return [fname, str(e)]
    render = LilypondOutput.LilypondRenderer(pieceObj, fname)
    try:
        render.run()
    except Exception as e:
        return [render.lyfile, str(e)]
    if not os.path.exists(render.pdf):
        return render.lyfile
Exemple #2
0
    def startRenderingTask(self, fname):
        """
        method which parses a piece, then runs the renderer class on it which takes the lilypond
        output, runs lilypond on it and gets the pdf. This is not generally called directly,
        but rather called by a thread class in thread_classes.py

        * Parameter fname: xml filename

        * Return value: list of problems encountered
        """
        errorList = []
        parser = MxmlParser.MxmlParser()
        piece_obj = None

        path_to_file = os.path.join(self.folder, fname)

        try:
            piece_obj = parser.parse(path_to_file)
        except Exceptions.DrumNotImplementedException as e:
            errorList.append(
                "Drum tab found in piece: this application does not handle drum tab.")
            logger.exception(
                "Drum tab found in piece:{} - {}".format(fname, str(e)))
        except Exceptions.TabNotImplementedException as e:
            errorList.append(
                "Guitar tab found in this piece: this application does not handle guitar tab.")
            logger.exception(
                "Guitar tab found in piece:{} - {}".format(fname, str(e)))
        except SAXParseException as e:
            errorList.append(
                "Sax parser had a problem with this file:" + str(e))
            logger.exception(
                "Exception SAX parsing file:{} - {}".format(fname, str(e)))

        try:
            loader = LilypondOutput.LilypondRenderer(
                piece_obj,
                os.path.join(
                    self.folder,
                    fname))
            loader.run()
        except BaseException as e:
            errorList.append(str(e))
            logger.exception(
                "Exception rendering lilypond with file:{} - {}".format(fname, str(e)))
        return errorList
Exemple #3
0
    def setUp(self):
        self.parser = MxmlParser.MxmlParser()
        self.tag_list = []
        self.attrs = []
        self.parser.piece.addPart(Part.Part(), index="P1")
        self.parser.tags.append("part")
        self.parser.attribs["part"] = {"id": "P1"}
        self.parser.StartTag("measure", {"number": "1"})
        self.parser.StartTag("divisions", {})
        self.parser.NewData("8")
        self.parser.EndTag("divisions")
        self.parser.StartTag("note", {})
        self.parser.StartTag("duration", {})
        self.parser.NewData("16")
        self.parser.EndTag("duration")
        self.parser.EndTag("note")
        self.parser.StartTag("note", {})
        self.parser.StartTag("duration", {})
        self.parser.NewData("16")
        self.parser.EndTag("duration")
        self.parser.EndTag("note")
        self.parser.data["staff_id"] = 2
        self.parser.StartTag("note", {})
        self.parser.StartTag("divisions", {})
        self.parser.NewData("8")
        self.parser.EndTag("divisions")
        self.parser.StartTag("note", {})
        self.parser.StartTag("duration", {})
        self.parser.NewData("16")
        self.parser.EndTag("duration")
        self.parser.EndTag("note")
        self.parser.StartTag("note", {})
        self.parser.StartTag("duration", {})
        self.parser.NewData("16")
        self.parser.EndTag("duration")
        self.parser.EndTag("note")
        self.parser.data["staff_id"] = 1

        self.measure = self.parser.piece.getPart("P1").getMeasure(1, 1)
Exemple #4
0
 def setUp(self):
     self.file = os.path.join(folder, "arpeggiosAndGlissandos.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     self.dontcleanup = True
     testRun.setUp(self)
Exemple #5
0
 def testRun(self):
     with self.assertRaises(Exceptions.DrumNotImplementedException):
         parser = MxmlParser.MxmlParser()
         self.item = parser.parse(self.file)
Exemple #6
0
    def setUp(self):
        self.file = os.path.join(folder, "accidentals.xml")
        parser = MxmlParser.MxmlParser()
        self.item = parser.parse(self.file)

        testRun.setUp(self)
Exemple #7
0
 def setUp(self):
     self.file = os.path.join(folder, "two_staves_one_part.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     testRun.setUp(self)
Exemple #8
0
 def setUp(self):
     self.file = os.path.join(folder, "TrillsFermataOrnaments.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     self.dontcleanup = True
     testRun.setUp(self)
Exemple #9
0
    def setUp(self):
        self.file = os.path.join(folder, "multiple_parts.xml")
        parser = MxmlParser.MxmlParser()
        self.item = parser.parse(self.file)

        testRun.setUp(self)
Exemple #10
0
 def setUp(self):
     self.file = os.path.join(folder, "fingering.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     testRun.setUp(self)
Exemple #11
0
 def setUp(self):
     self.file = os.path.join(folder, "duration_and_stem_direction.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     testRun.setUp(self)
Exemple #12
0
 def setUp(self):
     self.parser = MxmlParser.MxmlParser()
     self.tag_list = []
     self.attrs = []
Exemple #13
0
def parsePiece(name):
    parser = MxmlParser.MxmlParser()
    return parser.parse(name)
Exemple #14
0
 def setUp(self):
     self.fname = ""
     self.note_num = 0
     self.parser = MxmlParser.MxmlParser()
     self.folder = "/Users/charlottegodley/PycharmProjects/FYP/implementation/primaries/SampleMusicXML/testcases"
Exemple #15
0
 def setUp(self):
     self.file = os.path.join(folder, "repeat-barlines.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     testRun.setUp(self)
Exemple #16
0
 def setUp(self):
     self.file = os.path.join(folder, "breathMarks.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     self.dontcleanup = True
     testRun.setUp(self)
Exemple #17
0
 def setUp(self):
     self.file = os.path.join(folder, "keySignatures.xml")
     parser = MxmlParser.MxmlParser()
     self.item = parser.parse(self.file)
     testRun.setUp(self)