diff options
author | Guido van Rossum <guido@python.org> | 1998-03-26 22:14:20 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-03-26 22:14:20 (GMT) |
commit | 548703a1b81f6adf68a3dd4b497a88f5c4a31f4a (patch) | |
tree | 8fc46e5faa2a7e82e6748995c555d7fe0b781449 /Lib/dos-8x3/reconver.py | |
parent | 65e5399081e23d7b1efbf685096c65d0a0ab912b (diff) | |
download | cpython-548703a1b81f6adf68a3dd4b497a88f5c4a31f4a.zip cpython-548703a1b81f6adf68a3dd4b497a88f5c4a31f4a.tar.gz cpython-548703a1b81f6adf68a3dd4b497a88f5c4a31f4a.tar.bz2 |
The usual.
Diffstat (limited to 'Lib/dos-8x3/reconver.py')
-rw-r--r-- | Lib/dos-8x3/reconver.py | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/Lib/dos-8x3/reconver.py b/Lib/dos-8x3/reconver.py index f0b61fc..2b044b6 100644 --- a/Lib/dos-8x3/reconver.py +++ b/Lib/dos-8x3/reconver.py @@ -108,36 +108,36 @@ def convert(s, syntax=None): """ table = mastertable.copy() if syntax is None: - syntax = regex.get_syntax() + syntax = regex.get_syntax() if syntax & RE_NO_BK_PARENS: - del table[r'\('], table[r'\)'] - del table['('], table[')'] + del table[r'\('], table[r'\)'] + del table['('], table[')'] if syntax & RE_NO_BK_VBAR: - del table[r'\|'] - del table['|'] + del table[r'\|'] + del table['|'] if syntax & RE_BK_PLUS_QM: - table['+'] = r'\+' - table['?'] = r'\?' - table[r'\+'] = '+' - table[r'\?'] = '?' + table['+'] = r'\+' + table['?'] = r'\?' + table[r'\+'] = '+' + table[r'\?'] = '?' if syntax & RE_NEWLINE_OR: - table['\n'] = '|' + table['\n'] = '|' res = "" i = 0 end = len(s) while i < end: - c = s[i] - i = i+1 - if c == '\\': - c = s[i] - i = i+1 - key = '\\' + c - key = table.get(key, key) - res = res + key - else: - c = table.get(c, c) - res = res + c + c = s[i] + i = i+1 + if c == '\\': + c = s[i] + i = i+1 + key = '\\' + c + key = table.get(key, key) + res = res + key + else: + c = table.get(c, c) + res = res + c return res @@ -155,21 +155,21 @@ def quote(s, quote=None): """ if quote is None: - q = "'" - altq = "'" - if q in s and altq not in s: - q = altq + q = "'" + altq = "'" + if q in s and altq not in s: + q = altq else: - assert quote in ('"', "'") - q = quote + assert quote in ('"', "'") + q = quote res = q for c in s: - if c == q: c = '\\' + c - elif c < ' ' or c > '~': c = "\\%03o" % ord(c) - res = res + c + if c == q: c = '\\' + c + elif c < ' ' or c > '~': c = "\\%03o" % ord(c) + res = res + c res = res + q if '\\' in res: - res = 'r' + res + res = 'r' + res return res @@ -179,7 +179,7 @@ def main(): s = eval(sys.stdin.read()) sys.stdout.write(quote(convert(s))) if sys.stdout.isatty(): - sys.stdout.write("\n") + sys.stdout.write("\n") if __name__ == '__main__': |