From 636e60e389b30f2f6a2e3679d733a37b9a511221 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Tue, 18 Mar 2014 12:26:16 +0100 Subject: Python 3: Replace string functions with str methods --- paste/util/datetimeutil.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'paste/util') diff --git a/paste/util/datetimeutil.py b/paste/util/datetimeutil.py index b1a7f38..c19e001 100644 --- a/paste/util/datetimeutil.py +++ b/paste/util/datetimeutil.py @@ -76,7 +76,7 @@ def parse_timedelta(val): """ if not val: return None - val = string.lower(val) + val = val.lower() if "." in val: val = float(val) return timedelta(hours=int(val), minutes=60*(val % 1.0)) @@ -84,9 +84,9 @@ def parse_timedelta(val): fMin = ("m" in val or ":" in val) fFraction = "." in val for noise in "minu:teshour()": - val = string.replace(val, noise, ' ') - val = string.strip(val) - val = string.split(val) + val = val.replace(noise, ' ') + val = val.strip() + val = val.split() hr = 0.0 mi = 0 val.reverse() @@ -121,12 +121,12 @@ def parse_time(val): if not val: return None hr = mi = 0 - val = string.lower(val) - amflag = (-1 != string.find(val, 'a')) # set if AM is found - pmflag = (-1 != string.find(val, 'p')) # set if PM is found + val = val.lower() + amflag = (-1 != val.find('a')) # set if AM is found + pmflag = (-1 != val.find('p')) # set if PM is found for noise in ":amp.": - val = string.replace(val, noise, ' ') - val = string.split(val) + val = val.replace(noise, ' ') + val = val.split() if len(val) > 1: hr = int(val[0]) mi = int(val[1]) @@ -198,7 +198,7 @@ _wkdy = ("mon", "tue", "wed", "thu", "fri", "sat", "sun") def parse_date(val): if not(val): return None - val = string.lower(val) + val = val.lower() now = None # optimized check for YYYY-MM-DD @@ -243,9 +243,9 @@ def parse_date(val): # ok, standard parsing yr = mo = dy = None for noise in ('/', '-', ',', '*'): - val = string.replace(val, noise, ' ') + val = val.replace(noise, ' ') for noise in _wkdy: - val = string.replace(val, noise, ' ') + val = val.replace(noise, ' ') out = [] last = False ldig = False @@ -260,7 +260,7 @@ def parse_date(val): ldig = False last = True out.append(ch) - val = string.split("".join(out)) + val = "".join(out).split() if 3 == len(val): a = _number(val[0]) b = _number(val[1]) -- cgit v1.2.1