Mercurial > dottes
comparison 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 |
comparison
equal
deleted
inserted
replaced
325:21615733c3f3 | 326:27f29e8aafea |
---|---|
107 def process(inf, options): | 107 def process(inf, options): |
108 n = options.index | 108 n = options.index |
109 for line in inf: | 109 for line in inf: |
110 line = line.strip() | 110 line = line.strip() |
111 if len(line) > 2 and line[0] == options.field and line[1] == ':': | 111 if len(line) > 2 and line[0] == options.field and line[1] == ':': |
112 if len(options.contains) > 0: | |
113 if line.find(options.contains) < 0: | |
114 continue | |
112 if n > 1: | 115 if n > 1: |
113 n = n - 1 | 116 n = n - 1 |
114 else: | 117 else: |
115 print(convertTitle(line[2:].strip(), options)) | 118 print(convertTitle(line[2:].strip(), options)) |
116 break | 119 break |
127 help="format ouput for LaTeX") | 130 help="format ouput for LaTeX") |
128 parser.add_option("-n", "--index", dest="index", | 131 parser.add_option("-n", "--index", dest="index", |
129 action="store", type="int", default=1, | 132 action="store", type="int", default=1, |
130 help="report INDEXth value [default: %default]", | 133 help="report INDEXth value [default: %default]", |
131 metavar="INDEX") | 134 metavar="INDEX") |
135 parser.add_option("-c", "--contains", dest="contains", | |
136 action="store", type="string", default="", | |
137 help="report only if line contains CONTENT", | |
138 metavar="CONTENT") | |
132 (options, args) = parser.parse_args() | 139 (options, args) = parser.parse_args() |
133 | 140 |
134 if options.html and options.latex: | 141 if options.html and options.latex: |
135 sys.exit("You must choose one of HTML or LaTeX output") | 142 sys.exit("You must choose one of HTML or LaTeX output") |
136 | 143 |