diff musiccutter.py @ 22:65e8298f5800

Remove extension and path name from title. Put destination file in CWD.
author Daniel O'Connor <darius@dons.net.au>
date Fri, 29 Apr 2016 17:36:31 +0930
parents c710c4c3f44f
children 63d13efa040f
line wrap: on
line diff
--- 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