OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # (setq py-indent-offset 4) | 2 # (setq py-indent-offset 4) |
3 | 3 |
4 | 4 |
5 import string | 5 import string |
6 import re | 6 import re |
7 import sys | 7 import sys |
8 import lilylib | 8 import lilylib |
9 | 9 |
10 _ = lilylib._ | 10 _ = lilylib._ |
(...skipping 3908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3919 stderr_write (_ ("Now \"output-attributes\" (association list) is used i
nstead.") + "\n") | 3919 stderr_write (_ ("Now \"output-attributes\" (association list) is used i
nstead.") + "\n") |
3920 stderr_write (UPDATE_MANUALLY) | 3920 stderr_write (UPDATE_MANUALLY) |
3921 | 3921 |
3922 # First, for manual editing cases we convert 'id' to 'output-attributes' | 3922 # First, for manual editing cases we convert 'id' to 'output-attributes' |
3923 # because Grob.output-attributes.id = #(lambda ... ) will not work. | 3923 # because Grob.output-attributes.id = #(lambda ... ) will not work. |
3924 # Then for the rest we convert 'id' to 'output-attributes.id' | 3924 # Then for the rest we convert 'id' to 'output-attributes.id' |
3925 str = re.sub (manual_edits, r"\1output-attributes\2", str) | 3925 str = re.sub (manual_edits, r"\1output-attributes\2", str) |
3926 str = re.sub (automatic, r"\1output-attributes.id", str) | 3926 str = re.sub (automatic, r"\1output-attributes.id", str) |
3927 return str | 3927 return str |
3928 | 3928 |
| 3929 matchscmarg = (r'(?:[a-zA-Z_][-a-zA-Z_0-9]*|"(?:[^\\"]|\\.)*"|[-+]?[0-9.]+|\(' |
| 3930 + paren_matcher (10) + r"\))") |
| 3931 |
| 3932 @rule ((2, 19, 65), r"""\note #"4." -> \note {4.}""") |
| 3933 def conv (str): |
| 3934 def repl1ly (m): |
| 3935 if m.group (2)[0] in "blm": |
| 3936 return m.group(1) + "{\\" + m.group(2) + "}" |
| 3937 return m.group (1) + "{" + m.group (2) + "}" |
| 3938 def repl1scm (m): |
| 3939 return ("%s(ly:make-duration %d %d)" % |
| 3940 (m.group (1), |
| 3941 {"1": 0, "2": 1, "4": 2, "8": 3, "16": 4, |
| 3942 "32": 5, "64": 6, "128": 7, "256": 8, |
| 3943 "breve": -1, "longa": -2, "maxima": -4}[m.group (2)], |
| 3944 m.end (3) - m.start (3))) |
| 3945 def replly (m): |
| 3946 return re.sub (r'(\\note\s*)#?"((?:1|2|4|8|16|32|64|128|256' |
| 3947 r'|breve|longa|maxima)\s*\.*)"', |
| 3948 repl1ly, m.group (0)) |
| 3949 def replscm (m): |
| 3950 return re.sub (r'"()(1|2|4|8|16|32|64|128|256' |
| 3951 r'|breve|longa|maxima)\s*(\.*)"', |
| 3952 repl1scm, m.group (0)) |
| 3953 def replmarkup (m): |
| 3954 return re.sub (r'(#:note\s+)"(1|2|4|8|16|32|64|128|256' |
| 3955 r'|breve|longa|maxima)\s*(\.*)"', |
| 3956 repl1scm, m.group (0)) |
| 3957 str = re.sub (matchmarkup, replly, str) |
| 3958 str = re.sub (r"\(tuplet-number::(?:fraction-with-notes|non-default-fraction
-with-notes|append-note-wrapper)\s" + |
| 3959 paren_matcher (20) + r"\)", replscm, str) |
| 3960 str = re.sub (r'\(markup\s' + paren_matcher (20) + r'\)', |
| 3961 replmarkup, str) |
| 3962 return str |
| 3963 |
| 3964 |
3929 # Guidelines to write rules (please keep this at the end of this file) | 3965 # Guidelines to write rules (please keep this at the end of this file) |
3930 # | 3966 # |
3931 # - keep at most one rule per version; if several conversions should be done, | 3967 # - keep at most one rule per version; if several conversions should be done, |
3932 # concatenate them into a single "conv" function; | 3968 # concatenate them into a single "conv" function; |
3933 # | 3969 # |
3934 # - enclose strings to be localized with `_(' and `)'; | 3970 # - enclose strings to be localized with `_(' and `)'; |
3935 # | 3971 # |
3936 # - write rule for bumping major stable version with | 3972 # - write rule for bumping major stable version with |
3937 # | 3973 # |
3938 # _ ("bump version for release") | 3974 # _ ("bump version for release") |
3939 # | 3975 # |
3940 # as exact description. | 3976 # as exact description. |
OLD | NEW |