diff abcfield.py @ 326:27f29e8aafea

Add --contains flag to abcfield.py. Currently we rely on any N: field with a Change: subnotice being the first N: field. Add --contains field to abcfield.py to remove this restriction. Also use it to extract new subfield Credit: and add that if present to the tune information in print and on web.
author Jim Hague <jim.hague@acm.org>
date Sun, 04 Aug 2013 22:09:25 +0100
parents eedf65564226
children 760d0ae5acea
line wrap: on
line diff
--- a/abcfield.py	Sun Aug 04 21:28:05 2013 +0100
+++ b/abcfield.py	Sun Aug 04 22:09:25 2013 +0100
@@ -109,6 +109,9 @@
     for line in inf:
         line = line.strip()
         if len(line) > 2 and line[0] == options.field and line[1] == ':':
+            if len(options.contains) > 0:
+                if line.find(options.contains) < 0:
+                    continue
             if n > 1:
                 n = n - 1
             else:
@@ -129,6 +132,10 @@
                   action="store", type="int", default=1,
                   help="report INDEXth value [default: %default]",
                   metavar="INDEX")
+parser.add_option("-c", "--contains", dest="contains",
+                  action="store", type="string", default="",
+                  help="report only if line contains CONTENT",
+                  metavar="CONTENT")
 (options, args) = parser.parse_args()
 
 if options.html and options.latex: