lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix a few complaints in python/convertrules.py (issue 583290043 by a


From: dak
Subject: Re: Fix a few complaints in python/convertrules.py (issue 583290043 by address@hidden)
Date: Sat, 11 Jan 2020 16:51:25 -0800

Reviewers: hahnjo,


https://codereview.appspot.com/583290043/diff/557180043/python/convertrules.py
File python/convertrules.py (right):

https://codereview.appspot.com/583290043/diff/557180043/python/convertrules.py#newcode1774
python/convertrules.py:1774: str += "'" * (o + 1)
On 2020/01/08 08:17:25, hahnjo wrote:
I agree that this is equivalent, but still very confusing. I would
propose the
following which should highlight the intent:
o += 1
if o < 0:
     str += ',' * (-o)
elif o > 0:
     str += "'" * o

I thought about this but then considered it not significantly clearer.
Since the clarity is for readers of code rather than writers, I'll take
your opinion over mine here.

Description:
Fix a few complaints in python/convertrules.py

Please review this at https://codereview.appspot.com/583290043/

Affected files (+4, -11 lines):
  M python/convertrules.py


Index: python/convertrules.py
diff --git a/python/convertrules.py b/python/convertrules.py
index f412800666fcbf833a919869acd7bdb0d1b0f481..24e86e789914f39015413a973bcf61eaacb25247 100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -1759,13 +1759,7 @@ def conv (str):
 @rule ((2, 1, 27), "property transposing -> tuning")
 def conv (str):
     def subst (m):
-        g = int (m.group (2))
-        o = g / 12
-        g -= o * 12
-        if g <  0:
-            g += 12
-            o -= 1
-
+        (o, g) = divmod (int (m.group (2)), 12)

lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
         s = len (lower_pitches) -1
@@ -1774,9 +1768,9 @@ def conv (str):

         str = 'cdefgab' [s]
         str += ['eses', 'es', '', 'is', 'isis'][a + 2]
-        if o < 0:
+        if o < -1:
             str += ',' * (-o - 1)
-        elif o >= 0:
+        elif o > -1:
             str += "'" * (o + 1)

         return '\\transposition %s ' % str
@@ -3218,7 +3212,6 @@ def paren_matcher (n):
     # parens inside; add the outer parens yourself if needed.
     # Nongreedy.
     return r"[^()]*?(?:\("*n+r"[^()]*?"+r"\)[^()]*?)*?"*n
-    return

 def undollar_scm (m):
     return re.sub (r"\$(.?)", r"\1", m.group (0))
@@ -3977,7 +3970,7 @@ def conv (str):
     str = re.sub (r'\\powerChords', '', str)
str = re.sub (r'"scripts\.trilelement"', r'"scripts.trillelement"', str)
     str = re.sub (r"\\fermataMarkup", r"\\fermata", str)
-    if re.search (r"#[banter|jazz]-chord-names", str):
+    if re.search (r"#(banter|jazz)-chordnames", str):
         stderr_write (NOT_SMART % "alternative chord naming functions")
         stderr_write (UPDATE_MANUALLY)
     return str





reply via email to

[Prev in Thread] Current Thread [Next in Thread]