comparison abctemplate.py @ 726:833e6185b6a2 build-default-282

Add fulltitle to template fields. fulltitle is title + [(" subtitle ")"] if subtitle is present. To do: extend full title to next and prev. this means exposing it in abcfield.py.
author Jim Hague <jim.hague@acm.org>
date Wed, 11 Oct 2017 17:09:31 +0100
parents 7e9d5852c802
children c81a1ed21877
comparison
equal deleted inserted replaced
725:f9a554e858f3 726:833e6185b6a2
19 # Templates are read from file, and are in Python standard library format. 19 # Templates are read from file, and are in Python standard library format.
20 # The following values are substituted: 20 # The following values are substituted:
21 # * name. The file base name. Base filename without extension. 21 # * name. The file base name. Base filename without extension.
22 # * title. The tune title. 22 # * title. The tune title.
23 # * subtitle. The tune subtitle (second Title field), if any. 23 # * subtitle. The tune subtitle (second Title field), if any.
24 # * fulltitle. The tune title followed, if it exists, by " (" subtitle ")"
24 # * tradition. The Morris tradition the dance tune is from. 25 # * tradition. The Morris tradition the dance tune is from.
25 # * composer. The tune composer. 26 # * composer. The tune composer.
26 # * key. The tune key. 27 # * key. The tune key.
27 # * parts. The tune parts order (A(AB2)3 etc.). 28 # * parts. The tune parts order (A(AB2)3 etc.).
28 # * changefile. The name of the 'change' file, if any. 29 # * changefile. The name of the 'change' file, if any.
35 36
36 import argparse 37 import argparse
37 import pathlib 38 import pathlib
38 import string 39 import string
39 40
40 from abcfield import getFieldDisplayText 41 from abcfield import getFieldDisplayText, getFullTitle
41 42
42 if __name__ == "__main__": 43 if __name__ == "__main__":
43 parser = argparse.ArgumentParser(description='Substitute values from ABC file into template.') 44 parser = argparse.ArgumentParser(description='Substitute values from ABC file into template.')
44 parser.add_argument('-l', '--latex', dest='latex', 45 parser.add_argument('-l', '--latex', dest='latex',
45 action='store_true', 46 action='store_true',
66 vars["historyvisibility"] = "no" 67 vars["historyvisibility"] = "no"
67 68
68 vars["name"] = fname 69 vars["name"] = fname
69 vars["title"] = getFieldDisplayText(lines, fdir, "T", latex=args.latex) 70 vars["title"] = getFieldDisplayText(lines, fdir, "T", latex=args.latex)
70 vars["subtitle"] = getFieldDisplayText(lines, fdir, "T", n=2, latex=args.latex) 71 vars["subtitle"] = getFieldDisplayText(lines, fdir, "T", n=2, latex=args.latex)
72 vars["fulltitle"] = getFullTitle(lines, fdir, latex=args.latex)
71 vars["tradition"] = getFieldDisplayText(lines, fdir, "A", latex=args.latex) 73 vars["tradition"] = getFieldDisplayText(lines, fdir, "A", latex=args.latex)
72 vars["composer"] = getFieldDisplayText(lines, fdir, "C", latex=args.latex) 74 vars["composer"] = getFieldDisplayText(lines, fdir, "C", latex=args.latex)
73 vars["key"] = getFieldDisplayText(lines, fdir, "K", latex=args.latex) 75 vars["key"] = getFieldDisplayText(lines, fdir, "K", latex=args.latex)
74 vars["parts"] = getFieldDisplayText(lines, fdir, "P", latex=args.latex) 76 vars["parts"] = getFieldDisplayText(lines, fdir, "P", latex=args.latex)
75 vars["notes"] = getFieldDisplayText(lines, fdir, "N", starts="Dottes:", latex=args.latex) 77 vars["notes"] = getFieldDisplayText(lines, fdir, "N", starts="Dottes:", latex=args.latex)