From: François Pinard Date: Mon, 18 Feb 2008 02:43:35 +0000 (-0500) Subject: Suite du passage de Python 1.5.2 à Python 2.2 X-Git-Tag: v3.7-beta1~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a100102100a1e69b2ec3b58c5bc5660385ea1aa4;p=recode Suite du passage de Python 1.5.2 à Python 2.2 --- diff --git a/src/mergelex.py b/src/mergelex.py index 2e04e06..f7f772d 100644 --- a/src/mergelex.py +++ b/src/mergelex.py @@ -20,7 +20,7 @@ # This Python script merges several Flex sources intended for `recode'. # It requires Flex 2.5 or later. -import re, string, sys +import re, sys # Initial comments. section0 = ["/* This file is generated automatically by `mergelex.py'. */\n"] @@ -39,12 +39,11 @@ section2 = ["%%\n" # Rest of C code. section3 = ["%%\n"] -comment_done = 0 -within_C_code = 0 +within_C_code = False definitions = {} section = 3 -while 1: +while True: line = sys.stdin.readline() if not line: break @@ -91,14 +90,14 @@ while 1: # by a %} line. if line[:2] == '%{': - within_C_code = 1 + within_C_code = True section1.append('\n') section1.append(line) continue if line[:2] == '%}': section1.append(line) section1.append('\n') - within_C_code = 0 + within_C_code = False continue if within_C_code: section1.append(line) @@ -108,8 +107,8 @@ while 1: # Conflicting declaractions are reported at beginning of output. if section == 1 and line[0] not in (' ', '\t', '\n'): - key, rest = string.split(line, None, 1) - if definitions.has_key(key): + key, rest = line.split(None, 1) + if key in definitions: if definitions[key] != line: sys.stderr.write("** Conflicting definition: %s" % line) else: diff --git a/tests/bigauto.py b/tests/bigauto.py index 9b2141e..8785d23 100755 --- a/tests/bigauto.py +++ b/tests/bigauto.py @@ -22,7 +22,7 @@ both as a starting and ending points. If there is no such non-option argument, all possible possible recodings are considered. """ -import os, string, sys +import os, sys def main(*arguments): recode_options = [] @@ -37,7 +37,7 @@ def main(*arguments): os.remove(work_name) create_data(work_name, recode_options, charset_options) report = Report() - report.digest_data(open(work_name).readline) + report.digest_data(file(work_name).readline) report.produce_report(sys.stdout.write) os.remove(work_name) @@ -47,13 +47,13 @@ def create_data(name, recode_options, charset_options): charsets = charset_options else: charsets = [] - for line in os.popen('recode -l').readlines(): - charset = string.split(line)[0] + for line in os.popen('recode -l'): + charset = line.split()[0] if charset[0] in ':/': continue charsets.append(charset) # Do the work, calling a subshell once per `before' value. - recode_call = 'recode