comparison abctemplate.py @ 594:60749c792cde

Replace Change and Credit with Markdown-enabled Notes section. Data in Notes is taken from N: section starting "Dottes:".
author Jim Hague <jim.hague@acm.org>
date Wed, 02 Nov 2016 15:02:06 +0000
parents afc031477784
children ed823ea54c83
comparison
equal deleted inserted replaced
593:82e818c41e81 594:60749c792cde
54 54
55 with args.input as f: 55 with args.input as f:
56 lines = f.readlines() 56 lines = f.readlines()
57 57
58 input_path = pathlib.Path(args.input.name) 58 input_path = pathlib.Path(args.input.name)
59 fname = input_path.stem
60 fdir = input_path.parent
59 61
60 vars = dict() 62 vars = dict()
61 vars["changename"] = "" 63 vars["notesvisibility"] = "no"
62 vars["changetitle"] = ""
63 vars["changevisibility"] = "no"
64 vars["creditvisibility"] = "no"
65 64
66 vars["name"] = input_path.stem 65 vars["name"] = fname
67 vars["title"] = getFieldDisplayText(lines, "T", latex=args.latex) 66 vars["title"] = getFieldDisplayText(lines, fdir, "T", latex=args.latex)
68 vars["subtitle"] = getFieldDisplayText(lines, "T", n=2, latex=args.latex) 67 vars["subtitle"] = getFieldDisplayText(lines, fdir, "T", n=2, latex=args.latex)
69 vars["composer"] = getFieldDisplayText(lines, "C", latex=args.latex) 68 vars["composer"] = getFieldDisplayText(lines, fdir, "C", latex=args.latex)
70 vars["key"] = getFieldDisplayText(lines, "K", latex=args.latex) 69 vars["key"] = getFieldDisplayText(lines, fdir, "K", latex=args.latex)
71 vars["changefile"] = getFieldDisplayText(lines, "N", starts="Change:", latex=args.latex) 70 vars["notes"] = getFieldDisplayText(lines, fdir, "N", starts="Dottes:", latex=args.latex)
72 vars["credit"] = getFieldDisplayText(lines, "N", starts="Credit:", latex=args.latex) 71 if vars["notes"]:
73 72 vars["notesvisibility"] = "yes"
74 if vars["changefile"]:
75 vars["changevisibility"] = "yes"
76 vars["changename"] = pathlib.Path(vars["changefile"]).stem
77 cf = pathlib.Path(input_path.parent, vars["changefile"])
78 with cf.open() as f:
79 vars["changetitle"] = getFieldDisplayText(f, "T", latex=args.latex)
80
81 if vars["credit"]:
82 vars["creditvisibility"] = "yes"
83 73
84 for val in args.values: 74 for val in args.values:
85 keyval = val.partition("=") 75 keyval = val.partition("=")
86 vars[keyval[0]] = keyval[2] 76 vars[keyval[0]] = keyval[2]
87 77