# HG changeset patch # User Daniel O'Connor # Date 1461917191 -34200 # Node ID 65e8298f580095fd9a482add3819ce8d1f0ec33b # Parent c710c4c3f44fb4187a0ea616a54c2575f94d9e33 Remove extension and path name from title. Put destination file in CWD. diff -r c710c4c3f44f -r 65e8298f5800 musiccutter.py --- a/musiccutter.py Fri Apr 29 15:57:32 2016 +0930 +++ b/musiccutter.py Fri Apr 29 17:36:31 2016 +0930 @@ -4,7 +4,7 @@ import itertools import math import mido -import os +import os.path import reportlab.lib.colors import reportlab.pdfgen.canvas from reportlab.lib.units import mm @@ -20,6 +20,7 @@ # Notes are read from right to left m = Midi2PDF('notes', 120, 155, 5.5, 3.0, 6.0, 50, False, False, False, False, 12, 10, 'Helvetica', 12) base, ext = os.path.splitext(filename) + base = os.path.basename(base) m.processMidi(filename, base + '-%02d.pdf') class Midi2PDF(object): @@ -56,7 +57,8 @@ pdf = reportlab.pdfgen.canvas.Canvas(file(outpat % (i + 1), 'w'), pagesize = (self.pagewidth * mm, self.pageheight * mm)) pdfs.append(pdf) - title = midifile + title = os.path.basename(midifile) + title, ext = os.path.splitext(title) for ev in midi: if ev.type == 'text' and ctime == 0: title = ev.text