Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(983)

Unified Diff: python/convertrules.py

Issue 328050043: Change \note markup command to get a duration
Patch Set: Run scripts/auxiliar/update-with-convert-ly.sh Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lily/parser.yy ('k') | python/musicexp.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: python/convertrules.py
diff --git a/python/convertrules.py b/python/convertrules.py
index b3000400da3848a799ce35aec09116dcca2efba8..09e3d9c97214c01a81d1d039613ae0a95b9dee73 100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -3926,6 +3926,42 @@ def conv (str):
str = re.sub (automatic, r"\1output-attributes.id", str)
return str
+matchscmarg = (r'(?:[a-zA-Z_][-a-zA-Z_0-9]*|"(?:[^\\"]|\\.)*"|[-+]?[0-9.]+|\('
+ + paren_matcher (10) + r"\))")
+
+@rule ((2, 19, 65), r"""\note #"4." -> \note {4.}""")
+def conv (str):
+ def repl1ly (m):
+ if m.group (2)[0] in "blm":
+ return m.group(1) + "{\\" + m.group(2) + "}"
+ return m.group (1) + "{" + m.group (2) + "}"
+ def repl1scm (m):
+ return ("%s(ly:make-duration %d %d)" %
+ (m.group (1),
+ {"1": 0, "2": 1, "4": 2, "8": 3, "16": 4,
+ "32": 5, "64": 6, "128": 7, "256": 8,
+ "breve": -1, "longa": -2, "maxima": -4}[m.group (2)],
+ m.end (3) - m.start (3)))
+ def replly (m):
+ return re.sub (r'(\\note\s*)#?"((?:1|2|4|8|16|32|64|128|256'
+ r'|breve|longa|maxima)\s*\.*)"',
+ repl1ly, m.group (0))
+ def replscm (m):
+ return re.sub (r'"()(1|2|4|8|16|32|64|128|256'
+ r'|breve|longa|maxima)\s*(\.*)"',
+ repl1scm, m.group (0))
+ def replmarkup (m):
+ return re.sub (r'(#:note\s+)"(1|2|4|8|16|32|64|128|256'
+ r'|breve|longa|maxima)\s*(\.*)"',
+ repl1scm, m.group (0))
+ str = re.sub (matchmarkup, replly, str)
+ str = re.sub (r"\(tuplet-number::(?:fraction-with-notes|non-default-fraction-with-notes|append-note-wrapper)\s" +
+ paren_matcher (20) + r"\)", replscm, str)
+ str = re.sub (r'\(markup\s' + paren_matcher (20) + r'\)',
+ replmarkup, str)
+ return str
+
+
# Guidelines to write rules (please keep this at the end of this file)
#
# - keep at most one rule per version; if several conversions should be done,
« no previous file with comments | « lily/parser.yy ('k') | python/musicexp.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b