]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4811/2: convert-ly rule for nicer beatStructure syntax
authorDavid Kastrup <dak@gnu.org>
Wed, 23 Mar 2016 16:31:21 +0000 (17:31 +0100)
committerDavid Kastrup <dak@gnu.org>
Tue, 29 Mar 2016 06:01:04 +0000 (08:01 +0200)
python/convertrules.py

index 9de12567832817b4babd87e7594c8025dc0b3aff..3e43a281330f089304ed199745d0abf7a8b5598b 100644 (file)
@@ -3871,6 +3871,23 @@ def conv(str):
     str = re.sub (r"#'whiteout-box(?![a-z_-])\b", r"#'whiteout", str)
     return str
 
+@rule ((2, 19, 40), r"\time #'(2 3) ... -> \time 2,3 ...")
+def conv (str):
+    def repl (m):
+        return m.group(1) + re.sub (r"\s+", ",", m.group (2))
+
+    str = re.sub (r"(beatStructure\s*=\s*)#'\(([0-9]+(?:\s+[0-9]+)+)\)",
+                  repl, str)
+
+    str = re.sub (r"(\\time\s*)#'\(([0-9]+(?:\s+[0-9]+)+)\)", repl, str)
+    def repl (m):
+        subst = re.sub (r"\s+", ",", m.group (1))
+        return subst + (4 + len (m.group (1)) - len (subst)) * " " + m.group (2)
+
+    str = re.sub (r"#'\(([0-9]+(?:\s+[0-9]+)+)\)(\s+%\s*beatStructure)",
+                  repl, 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,