From e3be51aa65bc7573cc3b5c2e99499e8528dc2edf Mon Sep 17 00:00:00 2001 From: John Mandereau Date: Fri, 29 Feb 2008 15:50:56 +0100 Subject: [PATCH] Update Python deprecated string functions --- python/convertrules.py | 19 +++++++++---------- python/fontextract.py | 5 ++--- python/lilylib.py | 3 +-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/python/convertrules.py b/python/convertrules.py index 8c29dc99cf..22ed07ad60 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -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) diff --git a/python/fontextract.py b/python/fontextract.py index fa73a9961d..ee9505f37f 100644 --- a/python/fontextract.py +++ b/python/fontextract.py @@ -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: diff --git a/python/lilylib.py b/python/lilylib.py index cfa5e67d0a..f9cbff2c60 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -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): -- 2.39.2