From: Fred L. D. <fd...@us...> - 2001-06-05 14:53:10
|
Update of /cvsroot/grail/grail/src/bookmarks In directory usw-pr-cvs1:/tmp/cvs-serv24454 Modified Files: iso8601.py Log Message: Remove all use of the string module, but remain compatible with Python 1.5.2. The only functions this module used were the atoi()/atof(), which can be replaced with the built-in int()/float() functions even in Python 1.5.2. Index: iso8601.py =================================================================== RCS file: /cvsroot/grail/grail/src/bookmarks/iso8601.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** iso8601.py 1998/10/13 15:14:34 1.1 --- iso8601.py 2001/06/05 14:53:08 1.2 *************** *** 12,16 **** __version__ = '1.0' - import string import time --- 12,15 ---- *************** *** 101,109 **** def __extract_date(m): ! year = string.atoi(m.group("year"), 10) julian = m.group("julian") if julian: ! return __find_julian(year, string.atoi(julian, 10)) ! month = string.atoi(m.group("month"), 10) day = 1 if month is None: --- 100,108 ---- def __extract_date(m): ! year = int(m.group("year"), 10) julian = m.group("julian") if julian: ! return __find_julian(year, int(julian, 10)) ! month = int(m.group("month"), 10) day = 1 if month is None: *************** *** 114,118 **** day = m.group("day") if day: ! day = string.atoi(day) if not 1 <= day <= 31: raise ValueError, "illegal day number: " + m.group("day") --- 113,117 ---- day = m.group("day") if day: ! day = int(day, 10) if not 1 <= day <= 31: raise ValueError, "illegal day number: " + m.group("day") *************** *** 128,140 **** if not hours: return 0, 0, 0 ! hours = string.atoi(hours, 10) if not 0 <= hours <= 23: raise ValueError, "illegal hour number: " + m.group("hours") ! minutes = string.atoi(m.group("minutes"), 10) if not 0 <= minutes <= 59: raise ValueError, "illegal minutes number: " + m.group("minutes") seconds = m.group("seconds") if seconds: ! seconds = string.atof(seconds) if not 0 <= seconds <= 59: raise ValueError, "illegal seconds number: " + m.group("seconds") --- 127,139 ---- if not hours: return 0, 0, 0 ! hours = int(hours, 10) if not 0 <= hours <= 23: raise ValueError, "illegal hour number: " + m.group("hours") ! minutes = int(m.group("minutes"), 10) if not 0 <= minutes <= 59: raise ValueError, "illegal minutes number: " + m.group("minutes") seconds = m.group("seconds") if seconds: ! seconds = float(seconds) if not 0 <= seconds <= 59: raise ValueError, "illegal seconds number: " + m.group("seconds") *************** *** 153,160 **** if tzd == "Z": return 0 ! hours = string.atoi(m.group("tzdhours"), 10) minutes = m.group("tzdminutes") if minutes: ! minutes = string.atoi(minutes, 10) else: minutes = 0 --- 152,159 ---- if tzd == "Z": return 0 ! hours = int(m.group("tzdhours"), 10) minutes = m.group("tzdminutes") if minutes: ! minutes = int(minutes, 10) else: minutes = 0 |