Allow specific refnum selection with abcplay.py (e.g. collection.abc:1:5:6).
authorW. Trevor King <wking@drexel.edu>
Tue, 16 Nov 2010 17:54:35 +0000 (12:54 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 16 Nov 2010 17:54:35 +0000 (12:54 -0500)
posts/abcplay/abcplay.py

index 9d840895686659153378f3fc1a1a05f129c244aa..8f76f03813adacc1b83d9e896fe1d99f14e2aaea 100755 (executable)
@@ -22,6 +22,8 @@ from time import time
 from os import remove
 
 
+REFNUM_SEP = ':'
+
 class ABCPlayer (object):
     def __init__(self):
         f,self._tempfile = mkstemp(prefix='abcplay-', suffix='.midi')
@@ -33,7 +35,12 @@ class ABCPlayer (object):
 
     def play_files(self, filenames):
         for filename in filenames:
-            refnums = list(self._refnums(filename))
+            if REFNUM_SEP in filename:
+                fields = filename.split(REFNUM_SEP)
+                filename = fields[0]
+                refnums = fields[1:]
+            else:
+                refnums = list(self._refnums(filename))
             while len(refnums) > 0:
                 refnum = refnums.pop(0)
                 try: