Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv13280 Modified Files: text_file.py Log Message: Changed so lines that are all comment (or just whitespace + comment) are completely skipped, rather than being treated as blank lines (and then subject to the 'skip_blanks' flag). This allows us to process old-style Setup files, which rely on hello \\ # boo! there coming out as "hello there". Index: text_file.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/text_file.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** text_file.py 2000/09/16 18:09:22 1.12 --- text_file.py 2000/09/16 18:33:36 1.13 *************** *** 202,207 **** if pos == -1: # no "#" -- no comments pass ! elif pos == 0 or line[pos-1] != "\\": # it's a comment ! # Have to preserve the trailing newline, because it's # the job of a later step (rstrip_ws) to remove it -- --- 202,209 ---- if pos == -1: # no "#" -- no comments pass ! ! # It's definitely a comment -- either "#" is the first ! # character, or it's elsewhere and unescaped. ! elif pos == 0 or line[pos-1] != "\\": # Have to preserve the trailing newline, because it's # the job of a later step (rstrip_ws) to remove it -- *************** *** 213,216 **** --- 215,228 ---- line = line[0:pos] + eol + # If all that's left is whitespace, then skip line + # *now*, before we try to join it to 'buildup_line' -- + # that way constructs like + # hello \\ + # # comment that should be ignored + # there + # result in "hello there". + if string.strip(line) == "": + continue + else: # it's an escaped "#" line = string.replace (line, "\\#", "#") *************** *** 233,237 **** self.current_line[1] = self.current_line[1] + 1 else: ! self.current_line = [self.current_line, self.current_line+1] # just an ordinary line, read it as usual else: --- 245,250 ---- self.current_line[1] = self.current_line[1] + 1 else: ! self.current_line = [self.current_line, ! self.current_line+1] # just an ordinary line, read it as usual else: *************** *** 272,276 **** return line ! # end readline --- 285,289 ---- return line ! # readline () *************** *** 299,317 **** line 3 \\ continues on next line """ - - # result 1: no fancy options result1 = map (lambda x: x + "\n", string.split (test_data, "\n")[0:-1]) # result 2: just strip comments ! result2 = ["\n", "\n", "line 3 \\\n", " continues on next line\n"] # result 3: just strip blank lines ! result3 = ["# test file\n", "line 3 \\\n", " continues on next line\n"] # result 4: default, strip comments, blank lines, and trailing whitespace ! result4 = ["line 3 \\", " continues on next line"] # result 5: strip comments and blanks, plus join lines (but don't --- 312,335 ---- line 3 \\ + # intervening comment continues on next line """ # result 1: no fancy options result1 = map (lambda x: x + "\n", string.split (test_data, "\n")[0:-1]) # result 2: just strip comments ! result2 = ["\n", ! "line 3 \\\n", ! " continues on next line\n"] # result 3: just strip blank lines ! result3 = ["# test file\n", ! "line 3 \\\n", ! "# intervening comment\n", ! " continues on next line\n"] # result 4: default, strip comments, blank lines, and trailing whitespace ! result4 = ["line 3 \\", ! " continues on next line"] # result 5: strip comments and blanks, plus join lines (but don't
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4