diff options
author | Guido van Rossum <guido@python.org> | 1991-12-16 13:10:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-12-16 13:10:14 (GMT) |
commit | befa2936d0179c25c76b343c7d4a0ef14635d928 (patch) | |
tree | e9bb55ea80be539b25facfb42f1cb457b7907d1e /Lib/irix5 | |
parent | a594fabbfae0853b1261d53caa8281fb7e8fa370 (diff) | |
download | cpython-befa2936d0179c25c76b343c7d4a0ef14635d928.zip cpython-befa2936d0179c25c76b343c7d4a0ef14635d928.tar.gz cpython-befa2936d0179c25c76b343c7d4a0ef14635d928.tar.bz2 |
Attempt at speeding up.
Diffstat (limited to 'Lib/irix5')
-rwxr-xr-x | Lib/irix5/flp.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/Lib/irix5/flp.py b/Lib/irix5/flp.py index 6aae82c..e64d555 100755 --- a/Lib/irix5/flp.py +++ b/Lib/irix5/flp.py @@ -118,10 +118,10 @@ class _newobj(): # Internal parsing routines. # def _parse_string(str): - return string.strip(str) + return str def _parse_num(str): - return eval(string.strip(str)) + return eval(str) def _parse_numlist(str): slist = string.split(str) @@ -144,16 +144,18 @@ _parse_func = { \ # This function parses a line, and returns either # a string or a tuple (name,value) +import regexp + def _parse_line(line): - try: - colonpos = string.index(line,':') - except string.index_error: - return string.strip(line) - name = line[:colonpos] - name = string.joinfields(string.split(name),'') - name = string.lower(name) + a = regexp.match('^([^:]*): *(.*)', line) + if not a: + return line + name = line[:a[1][1]] + if name[0] = 'N': + name = string.joinfields(string.split(name),'') + name = string.lower(name) name = string.upper(name[0]) + name[1:] - value = line[colonpos+1:] + value = line[a[2][0]:] try: pf = _parse_func[name] except RuntimeError: # BCOMPAT @@ -165,12 +167,12 @@ def _parse_line(line): def _readline(file): line = file.readline() - if line <> '': - line = line[:-1] - return line + if not line: + raise EOFError + return line[:-1] def _parse_1_line(file): - line = '' + line = _readline(file) while line = '': line = _readline(file) return _parse_line(line) |