]> git.donarmstrong.com Git - lilypond.git/commitdiff
Update Python deprecated string functions
authorJohn Mandereau <john.mandereau@gmail.com>
Fri, 29 Feb 2008 14:50:56 +0000 (15:50 +0100)
committerJohn Mandereau <john.mandereau@gmail.com>
Fri, 29 Feb 2008 14:50:56 +0000 (15:50 +0100)
python/convertrules.py
python/fontextract.py
python/lilylib.py

index 8c29dc99cfc928de5dc8cc1052e8ecaef7ddb244..22ed07ad6072fac7c4d164ca80813fef6bc13c91 100644 (file)
@@ -390,7 +390,7 @@ conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)'))
 
 def conv (str):
     def replace (match):
-       return '\\key %s;' % string.lower (match.group (1))
+       return '\\key %s;' % match.group (1).lower ()
 
     str = re.sub ("\\\\key ([^;]+);",  replace, str)
     return str
@@ -619,7 +619,7 @@ def regularize_id (str):
         elif x not in string.letters:
             x = 'x'
         elif x in string.lowercase and lastx == '_':
-            x = string.upper (x)
+            x = x.upper ()
         s = s + x
         lastx = x
     return s
@@ -991,7 +991,7 @@ def conv(str):
            'set-point-and-click!'
            ]
 
-    origre = r'\b(%s)' % string.join (changed, '|')
+    origre = r'\b(%s)' % '|'.join (changed)
 
     str = re.sub (origre, r'ly:\1',str)
     str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
@@ -1034,7 +1034,7 @@ def conv(str):
             'sfz',
             ]
 
-    origstr = string.join (kws, '|')
+    origstr = '|'.join (kws)
     str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
     return str
 conversions.append (((1,7,6), conv, 'note\\script -> note-\script'))
@@ -1296,9 +1296,8 @@ def sub_chord (m):
 
     ## end of while <>
 
-    suffix = string.join (slur_strs, '') + string.join (pslur_strs,
-                                                       '') \
-            + string.join (dyns, '')
+    suffix = ''.join (slur_strs) + ''.join (pslur_strs) \
+            + ''.join (dyns)
 
     return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
 
@@ -1651,7 +1650,7 @@ conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
 
 def conv (str):
     def func(match):
-       return "#'font-size = #%d" % (2*string.atoi (match.group (1)))
+       return "#'font-size = #%d" % (2*int (match.group (1)))
 
     str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
     str =re.sub (r"#'font-family\s*=\s*#'ancient",
@@ -1711,8 +1710,8 @@ def conv (str):
 
     def sub_note (match):
        dur = ''
-       log = string.atoi (match.group (1))
-       dots = string.atoi (match.group (2))
+       log = int (match.group (1))
+       dots = int (match.group (2))
 
        if log >= 0:
            dur = '%d' % (1 << log)
index fa73a9961d0e0610b477464de47a32ef45492b16..ee9505f37f8eaa7c4c8094d11c538cdfd84f4d10 100644 (file)
@@ -3,7 +3,6 @@ import re
 import getopt
 import sys
 import os
-import string
 
 dsr_font_regex = re.compile ('%%DocumentSuppliedResources: font (.*)')
 begin_font_regex = re.compile ('%%BeginFont: (.*)')
@@ -66,7 +65,7 @@ def extract_fonts_from_file (extract_from_this, font_dict, filename):
                in_font = 0
 
                if curr_font_name in extract_from_this:
-                   font_dict[curr_font_name] = string.join (curr_font, '')
+                   font_dict[curr_font_name] = ''.join (curr_font)
                    if verbose:
                        sys.stderr.write (_('Extracted %s')
                                          % curr_font_name + '\n')
@@ -79,7 +78,7 @@ def extract_fonts_from_file (extract_from_this, font_dict, filename):
 
        if extract_from_this:
            sys.stderr.write ("Failed to extract %s from %s\n"
-                             % (string.join (extract_from_this, ', '), filename))
+                             % (', '.join (extract_from_this), filename))
 
 def write_extracted_fonts (output_file_name, font_dict):
     if verbose:
index cfa5e67d0a7b0de58428f76b3ea96efac1cecdc1..f9cbff2c60a84ee84a3ebeb772e6eacc720b9adc 100644 (file)
@@ -11,7 +11,6 @@ import glob
 import os
 import re
 import shutil
-import string
 import sys
 import optparse
 
@@ -185,7 +184,7 @@ def strip_extension (f, ext):
 
 def search_exe_path (name):
     p = os.environ['PATH']
-    exe_paths = string.split (p, ':')
+    exe_paths = p.split (':')
     for e in exe_paths:
        full = os.path.join (e, name)
        if os.path.exists (full):