lilypond-devel
[Top][All Lists]
Advanced

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

python: replace <> with != (issue 561060043 by address@hidden)


From: matt . peveler
Subject: python: replace <> with != (issue 561060043 by address@hidden)
Date: Mon, 14 Oct 2019 17:17:15 -0700

Reviewers: ,

Description:
python: replace <> with !=

Replaces all usages of the deprecated <> operator with the
!= operator, where the former was also removed in Python3.
Both operators are available in Python2.4.

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

Affected files (+31, -31 lines):
  M python/convertrules.py
  M python/musicexp.py
  M python/musicxml.py
  M scripts/abc2ly.py
  M scripts/auxiliar/musicxml_generate_intervals.py
  M scripts/build/bib2texi.py
  M scripts/build/install.py
  M scripts/etf2ly.py
  M scripts/musicxml2ly.py


Index: python/convertrules.py
diff --git a/python/convertrules.py b/python/convertrules.py
index 356c6882311e68ba8555f70f58861afedc76de34..345e2a3ee61f3d425b3e831947171af1ada15ad1 100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -1017,7 +1017,7 @@ def sub_chord (m):
     for d in durs:
         if dur_str == '':
             dur_str = d
-        if dur_str <> d:
+        if dur_str != d:
             return '<%s>' % m.group (1)

     pslur_strs = ['']
@@ -1025,7 +1025,7 @@ def sub_chord (m):
     slur_strs = ['']

     last_str = ''
-    while last_str <> str:
+    while last_str != str:
         last_str = str

         def sub_tremolos (m, slur_strs = slur_strs):
Index: python/musicexp.py
diff --git a/python/musicexp.py b/python/musicexp.py
index c29b11b1543befc0aa6ea9fc843a336f519f0ca3..6064ffa5eea3838329340382bd47984505e8c0c0 100644
--- a/python/musicexp.py
+++ b/python/musicexp.py
@@ -173,8 +173,8 @@ class Duration:
             dur_str = '%d' % (1 << self.duration_log)
         dur_str += '.' * self.dots

-        if factor <> Rational(1, 1):
-            if factor.denominator() <> 1:
+        if factor != Rational(1, 1):
+            if factor.denominator() != 1:
dur_str += '*%d/%d' % (factor.numerator(), factor.denominator())
             else:
                 dur_str += '*%d' % factor.numerator()
@@ -1077,7 +1077,7 @@ class BarLine (Music):
'heavy': "|", 'light-light': "| |", 'light-heavy': "|.",
                        'heavy-light': ".|", 'heavy-heavy': ".|.", 'tick': "'",
                        'short': "'", 'none': "" }.get (self.type, None)
-        if bar_symbol <> None:
+        if bar_symbol != None:
             printer.dump ('\\bar "%s"' % bar_symbol)
         else:
             printer.dump ("|")
@@ -1432,9 +1432,9 @@ class FretEvent (MarkupEvent):
         self.elements = []
     def ly_expression (self):
         val = ""
-        if self.strings <> 6:
+        if self.strings != 6:
             val += "w:%s;" % self.strings
-        if self.frets <> 4:
+        if self.frets != 4:
             val += "h:%s;" % self.frets
         if self.barre and len (self.barre) >= 3:
val += "c:%s-%s-%s;" % (self.barre[0], self.barre[1], self.barre[2]+get_transpose("integer"))
Index: python/musicxml.py
diff --git a/python/musicxml.py b/python/musicxml.py
index 6b70e02cc580434436bedd82ac502a16bea94c98..ebf170831ac32bb91ab545e2c45bc77488d8afbf 100644
--- a/python/musicxml.py
+++ b/python/musicxml.py
@@ -104,7 +104,7 @@ class Xml_node:

     def get_unique_typed_child(self, klass):
         cn = self.get_typed_children(klass)
-        if len(cn) <> 1:
+        if len(cn) != 1:
             ly.error(self.__dict__)
             raise 'Child is not unique for',(klass, 'found', cn)

@@ -1309,12 +1309,12 @@ class Part(Music_xml_node):
if attributes_object and previous_measure and previous_measure.partial == 0:
                     length = attributes_object.get_measure_length()
                     new_now = measure_start_moment + length
-                    if now <> new_now:
+                    if now != new_now:
                         problem = 'incomplete'
                         if now > new_now:
                             problem = 'overfull'
                         ## only for verbose operation.
-                        if problem <> 'incomplete' and previous_measure:
+                        if problem != 'incomplete' and previous_measure:
previous_measure.message('%s measure? Expected: %s, Difference: %s' %(problem, now, new_now - now))
                     now = new_now
                 measure_start_moment = now
@@ -1435,7 +1435,7 @@ class Part(Music_xml_node):
                 if attributes_object and m.is_implicit():
                     length = attributes_object.get_measure_length()
                     measure_end = measure_start_moment + length
-                    if measure_end <> now:
+                    if measure_end != now:
                         m.partial = now
             previous_measure = m

Index: scripts/abc2ly.py
diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py
index 508cc93657ac53691a562e8221c06b4aace0b3f3..bb441d2b9514049373291ef3ba6e085d0ed2c558 100644
--- a/scripts/abc2ly.py
+++ b/scripts/abc2ly.py
@@ -894,7 +894,7 @@ def parse_duration (str, parser_state):


 def try_parse_rest (str, parser_state):
-    if not str or str[0] <> 'z' and str[0] <> 'x':
+    if not str or str[0] != 'z' and str[0] != 'x':
         return str

     __main__.lyric_idx = -1
@@ -1210,12 +1210,12 @@ def try_parse_bar (str,state):
     if str[:1] == '}':
         close_beam_state(state)

-    if bs <> None or state.next_bar != '':
+    if bs != None or state.next_bar != '':
         if state.parsing_tuplet:
             state.parsing_tuplet =0
             voices_append ('} ')

-    if bs <> None:
+    if bs != None:
         clear_bar_acc(state)
         close_beam_state(state)
         voices_append (bs)
Index: scripts/auxiliar/musicxml_generate_intervals.py
diff --git a/scripts/auxiliar/musicxml_generate_intervals.py b/scripts/auxiliar/musicxml_generate_intervals.py index 3c00715d1470b65fd9b3f3d14a8e069ddee97dc4..4a7f3678d375f34d4ff458a612ff185d6ef8769d 100755
--- a/scripts/auxiliar/musicxml_generate_intervals.py
+++ b/scripts/auxiliar/musicxml_generate_intervals.py
@@ -5,7 +5,7 @@ alterations = [-1, 0, 1]

 def print_note (octave, note, alteration):
print " <note>\n <pitch>\n <step>%s</step>" % notes[note]
-    if alteration <> 0:
+    if alteration != 0:
         print "          <alter>%s</alter>" % alteration
print " <octave>%s</octave>\n </pitch>\n <duration>1</duration>\n <voice>1</voice>\n <type>quarter</type>\n </note>" % octave

Index: scripts/build/bib2texi.py
diff --git a/scripts/build/bib2texi.py b/scripts/build/bib2texi.py
index b76a171a09263bd64c9ba1970a1b0439845aa3ac..c3caf572018da1b9a785a55c5526f55523f3c65c 100644
--- a/scripts/build/bib2texi.py
+++ b/scripts/build/bib2texi.py
@@ -77,7 +77,7 @@ if (show_output):
     sys.stdout.write (cmd)
 #And invoke it
 stat = os.system (cmd)
-if stat <> 0:
+if stat != 0:
     sys.stderr.write ("Bibtex exited with nonzero exit status!")
     sys.exit (1)

Index: scripts/build/install.py
diff --git a/scripts/build/install.py b/scripts/build/install.py
index 9818543a3f15022d74c0d1d0638e77b3af8cace8..7170a32e569fe70a10bc6d8e5a2cfd4dfed937e3 100644
--- a/scripts/build/install.py
+++ b/scripts/build/install.py
@@ -86,7 +86,7 @@ for f in args:

 for f in chown_me:
     os.chmod (f, mode)
-    if group <> None or owner <> None:
+    if group != None or owner != None:
         os.chown (f, group, owner)


Index: scripts/etf2ly.py
diff --git a/scripts/etf2ly.py b/scripts/etf2ly.py
index 40fc1903e6bcb0a48e0a6ce0076d93af94eb1fcd..ac8666d3d094936432ef97f130050df31f96ce8b 100644
--- a/scripts/etf2ly.py
+++ b/scripts/etf2ly.py
@@ -172,9 +172,9 @@ def rational_to_lily_skip (rat):
         d = d >> 1

     str = 's%d' % basedur
-    if n <> 1:
+    if n != 1:
         str = str + '*%d' % n
-    if d <> 1:
+    if d != 1:
         str = str + '/%d' % d

     return str
@@ -315,7 +315,7 @@ class Global_measure:
             log = log * 2
             dots = 0

-        if dots <> 0:
+        if dots != 0:
sys.stderr.write ("\nHuh? Beat duration has dots? (EDU Duration = %d)" % fdur)
         self.timesig = (beats, log)

@@ -571,7 +571,7 @@ class Staff:
                                  g.key_signature.signature_type())

                     last_key = g.key_signature
-                if last_time <> g.timesig :
+                if last_time != g.timesig :
                     e = e + "\\time %d/%d " % g.timesig
                     last_time = g.timesig

@@ -596,11 +596,11 @@ class Staff:
                 if g.force_break:
                     e = e + ' \\break '

-            if last_clef <> m.clef :
+            if last_clef != m.clef :
                 e = e + '\\clef "%s"' % lily_clef (m.clef)
                 last_clef = m.clef
             if e:
-                if gap <> (0,1):
+                if gap != (0,1):
                     k = k +' ' + rational_to_lily_skip (gap) + '\n'
                 gap = (0,1)
                 k = k + e
@@ -636,7 +636,7 @@ class Staff:
laystr = laystr + "%% non existent frame %d (skipped)\n" % x
                 if fr:
                     first_frame = fr
-                    if gap <> (0,1):
+                    if gap != (0,1):
laystr = laystr +'} %s {\n ' % rational_to_lily_skip (gap)
                         gap = (0,1)
                     laystr = laystr + fr.dump ()
@@ -832,7 +832,7 @@ Return: (value, rest-of-STR)
     elif str[0] == '"':
         str = str[1:]
         s = ''
-        while str and str[0] <> '"':
+        while str and str[0] != '"':
             s = s + str[0]
             str = str[1:]

@@ -895,7 +895,7 @@ def parse_etf_file (fn, tag_dict):
             else:
                 while content:
                     (v, content) = read_finale_value (content)
-                    if v <> None:
+                    if v != None:
                         parsed.append (v)

             tdict [indices].extend (parsed)
@@ -957,7 +957,7 @@ class Etf_file:
     def try_TP(self,  indices, contents):
         (nil, num) = indices

-        if self.tuplets[-1] == None or num <> self.tuplets[-1].start_note:
+        if self.tuplets[-1] == None or num != self.tuplets[-1].start_note:
             self.tuplets.append (Tuplet (num))

         self.tuplets[-1].append_finale (contents)
@@ -1130,7 +1130,7 @@ class Etf_file:
             return []


-        while c and c.number <> endno:
+        while c and c.number != endno:
d = c # hack to avoid problem with scripts/build/grand-replace.py
             thread.append (d)
             c = c.next
Index: scripts/musicxml2ly.py
diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py
index 94b314da4bdebcde71fc2a153186b33c1c4f3288..2f642ed1a464aeb6163641e44323e69dec164d08 100755
--- a/scripts/musicxml2ly.py
+++ b/scripts/musicxml2ly.py
@@ -373,8 +373,8 @@ def staff_attributes_to_lily_staff(mxl_attr):
         # staff.tablature_format = ???
     else:
         staff = musicexp.Staff()
-        # TODO: Handle case with lines <> 5!
-        if(lines != 5):
+        # TODO: Handle case with lines != 5!
+        if lines != 5:
staff.add_context_modification("\\override StaffSymbol #'line-count = #%s" % lines)

     return staff
@@ -2235,7 +2235,7 @@ def musicxml_voice_to_lily_voice(voice):
         staff = n.get_maybe_exist_named_child('staff')
         if staff:
             staff = staff.get_text()
- if current_staff and staff <> current_staff and not n.get_maybe_exist_named_child('chord'): + if current_staff and staff != current_staff and not n.get_maybe_exist_named_child('chord'):
                 voice_builder.add_command(musicexp.StaffChange(staff))
             current_staff = staff






reply via email to

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