Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 1 | """text_file |
| 2 | |
| 3 | provides the TextFile class, which gives an interface to text files |
| 4 | that (optionally) takes care of stripping comments, ignoring blank |
| 5 | lines, and joining lines with backslashes.""" |
| 6 | |
| 7 | # created 1999/01/12, Greg Ward |
| 8 | |
| 9 | __revision__ = "$Id$" |
| 10 | |
| 11 | from types import * |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 12 | import sys, os, string |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 13 | |
| 14 | |
| 15 | class TextFile: |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 16 | |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 17 | """Provides a file-like object that takes care of all the things you |
| 18 | commonly want to do when processing a text file that has some |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 19 | line-by-line syntax: strip comments (as long as "#" is your |
| 20 | comment character), skip blank lines, join adjacent lines by |
| 21 | escaping the newline (ie. backslash at end of line), strip |
| 22 | leading and/or trailing whitespace. All of these are optional |
| 23 | and independently controllable. |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 24 | |
| 25 | Provides a 'warn()' method so you can generate warning messages that |
| 26 | report physical line number, even if the logical line in question |
| 27 | spans multiple physical lines. Also provides 'unreadline()' for |
| 28 | implementing line-at-a-time lookahead. |
| 29 | |
| 30 | Constructor is called as: |
| 31 | |
| 32 | TextFile (filename=None, file=None, **options) |
| 33 | |
| 34 | It bombs (RuntimeError) if both 'filename' and 'file' are None; |
| 35 | 'filename' should be a string, and 'file' a file object (or |
| 36 | something that provides 'readline()' and 'close()' methods). It is |
| 37 | recommended that you supply at least 'filename', so that TextFile |
| 38 | can include it in warning messages. If 'file' is not supplied, |
| 39 | TextFile creates its own using the 'open()' builtin. |
| 40 | |
| 41 | The options are all boolean, and affect the value returned by |
| 42 | 'readline()': |
| 43 | strip_comments [default: true] |
| 44 | strip from "#" to end-of-line, as well as any whitespace |
| 45 | leading up to the "#" -- unless it is escaped by a backslash |
| 46 | lstrip_ws [default: false] |
| 47 | strip leading whitespace from each line before returning it |
| 48 | rstrip_ws [default: true] |
| 49 | strip trailing whitespace (including line terminator!) from |
| 50 | each line before returning it |
| 51 | skip_blanks [default: true} |
| 52 | skip lines that are empty *after* stripping comments and |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 53 | whitespace. (If both lstrip_ws and rstrip_ws are false, |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 54 | then some lines may consist of solely whitespace: these will |
| 55 | *not* be skipped, even if 'skip_blanks' is true.) |
| 56 | join_lines [default: false] |
| 57 | if a backslash is the last non-newline character on a line |
| 58 | after stripping comments and whitespace, join the following line |
| 59 | to it to form one "logical line"; if N consecutive lines end |
| 60 | with a backslash, then N+1 physical lines will be joined to |
| 61 | form one logical line. |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 62 | collapse_join [default: false] |
| 63 | strip leading whitespace from lines that are joined to their |
| 64 | predecessor; only matters if (join_lines and not lstrip_ws) |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 65 | |
| 66 | Note that since 'rstrip_ws' can strip the trailing newline, the |
| 67 | semantics of 'readline()' must differ from those of the builtin file |
| 68 | object's 'readline()' method! In particular, 'readline()' returns |
| 69 | None for end-of-file: an empty string might just be a blank line (or |
| 70 | an all-whitespace line), if 'rstrip_ws' is true but 'skip_blanks' is |
| 71 | not.""" |
| 72 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 73 | default_options = { 'strip_comments': 1, |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 74 | 'skip_blanks': 1, |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 75 | 'lstrip_ws': 0, |
| 76 | 'rstrip_ws': 1, |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 77 | 'join_lines': 0, |
| 78 | 'collapse_join': 0, |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Greg Ward | 782cdfe | 1999-03-23 14:00:06 +0000 | [diff] [blame] | 81 | def __init__ (self, filename=None, file=None, **options): |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 82 | """Construct a new TextFile object. At least one of 'filename' |
| 83 | (a string) and 'file' (a file-like object) must be supplied. |
| 84 | They keyword argument options are described above and affect |
| 85 | the values returned by 'readline()'.""" |
Greg Ward | 782cdfe | 1999-03-23 14:00:06 +0000 | [diff] [blame] | 86 | |
| 87 | if filename is None and file is None: |
| 88 | raise RuntimeError, \ |
| 89 | "you must supply either or both of 'filename' and 'file'" |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 90 | |
| 91 | # set values for all options -- either from client option hash |
| 92 | # or fallback to default_options |
| 93 | for opt in self.default_options.keys(): |
| 94 | if options.has_key (opt): |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 95 | setattr (self, opt, options[opt]) |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 96 | |
| 97 | else: |
| 98 | setattr (self, opt, self.default_options[opt]) |
| 99 | |
| 100 | # sanity check client option hash |
| 101 | for opt in options.keys(): |
| 102 | if not self.default_options.has_key (opt): |
| 103 | raise KeyError, "invalid TextFile option '%s'" % opt |
| 104 | |
Greg Ward | 782cdfe | 1999-03-23 14:00:06 +0000 | [diff] [blame] | 105 | if file is None: |
| 106 | self.open (filename) |
| 107 | else: |
| 108 | self.filename = filename |
| 109 | self.file = file |
| 110 | self.current_line = 0 # assuming that file is at BOF! |
Greg Ward | 787451b | 1999-03-26 21:48:59 +0000 | [diff] [blame] | 111 | |
Greg Ward | 91c488c | 1999-03-29 18:01:49 +0000 | [diff] [blame] | 112 | # 'linebuf' is a stack of lines that will be emptied before we |
| 113 | # actually read from the file; it's only populated by an |
| 114 | # 'unreadline()' operation |
| 115 | self.linebuf = [] |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 116 | |
| 117 | |
Greg Ward | 782cdfe | 1999-03-23 14:00:06 +0000 | [diff] [blame] | 118 | def open (self, filename): |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 119 | """Open a new file named 'filename'. This overrides both the |
| 120 | 'filename' and 'file' arguments to the constructor.""" |
| 121 | |
Greg Ward | 782cdfe | 1999-03-23 14:00:06 +0000 | [diff] [blame] | 122 | self.filename = filename |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 123 | self.file = open (self.filename, 'r') |
| 124 | self.current_line = 0 |
| 125 | |
| 126 | |
| 127 | def close (self): |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 128 | """Close the current file and forget everything we know about it |
| 129 | (filename, current line number).""" |
| 130 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 131 | self.file.close () |
| 132 | self.file = None |
| 133 | self.filename = None |
| 134 | self.current_line = None |
| 135 | |
| 136 | |
Greg Ward | f11296b | 2000-09-16 18:06:31 +0000 | [diff] [blame] | 137 | def gen_error (self, msg, line=None): |
| 138 | outmsg = [] |
| 139 | if line is None: |
| 140 | line = self.current_line |
| 141 | outmsg.append(self.filename + ", ") |
| 142 | if type (line) in (ListType, TupleType): |
| 143 | outmsg.append("lines %d-%d: " % tuple (line)) |
| 144 | else: |
| 145 | outmsg.append("line %d: " % line) |
| 146 | outmsg.append(str(msg)) |
| 147 | return string.join(outmsg, "") |
| 148 | |
| 149 | |
| 150 | def error (self, msg, line=None): |
| 151 | raise ValueError, "error: " + self.gen_error(msg, line) |
| 152 | |
Greg Ward | 4e5a7c7 | 1999-04-15 17:50:19 +0000 | [diff] [blame] | 153 | def warn (self, msg, line=None): |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 154 | """Print (to stderr) a warning message tied to the current logical |
| 155 | line in the current file. If the current logical line in the |
| 156 | file spans multiple physical lines, the warning refers to the |
| 157 | whole range, eg. "lines 3-5". If 'line' supplied, it overrides |
| 158 | the current line number; it may be a list or tuple to indicate a |
| 159 | range of physical lines, or an integer for a single physical |
| 160 | line.""" |
Greg Ward | f11296b | 2000-09-16 18:06:31 +0000 | [diff] [blame] | 161 | sys.stderr.write("warning: " + self.gen_error(msg, line) + "\n") |
Greg Ward | f6cdcd5 | 1999-01-18 17:08:16 +0000 | [diff] [blame] | 162 | |
| 163 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 164 | def readline (self): |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 165 | """Read and return a single logical line from the current file (or |
| 166 | from an internal buffer if lines have previously been "unread" |
| 167 | with 'unreadline()'). If the 'join_lines' option is true, this |
| 168 | may involve reading multiple physical lines concatenated into a |
| 169 | single string. Updates the current line number, so calling |
| 170 | 'warn()' after 'readline()' emits a warning about the physical |
| 171 | line(s) just read. Returns None on end-of-file, since the empty |
| 172 | string can occur if 'rstrip_ws' is true but 'strip_blanks' is |
| 173 | not.""" |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 174 | |
Greg Ward | 91c488c | 1999-03-29 18:01:49 +0000 | [diff] [blame] | 175 | # If any "unread" lines waiting in 'linebuf', return the top |
| 176 | # one. (We don't actually buffer read-ahead data -- lines only |
| 177 | # get put in 'linebuf' if the client explicitly does an |
| 178 | # 'unreadline()'. |
| 179 | if self.linebuf: |
| 180 | line = self.linebuf[-1] |
| 181 | del self.linebuf[-1] |
| 182 | return line |
| 183 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 184 | buildup_line = '' |
| 185 | |
| 186 | while 1: |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 187 | # read the line, make it None if EOF |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 188 | line = self.file.readline() |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 189 | if line == '': line = None |
| 190 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 191 | if self.strip_comments and line: |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 192 | |
| 193 | # Look for the first "#" in the line. If none, never |
| 194 | # mind. If we find one and it's the first character, or |
| 195 | # is not preceded by "\", then it starts a comment -- |
| 196 | # strip the comment, strip whitespace before it, and |
| 197 | # carry on. Otherwise, it's just an escaped "#", so |
| 198 | # unescape it (and any other escaped "#"'s that might be |
| 199 | # lurking in there) and otherwise leave the line alone. |
| 200 | |
| 201 | pos = string.find (line, "#") |
| 202 | if pos == -1: # no "#" -- no comments |
| 203 | pass |
| 204 | elif pos == 0 or line[pos-1] != "\\": # it's a comment |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 205 | |
| 206 | # Have to preserve the trailing newline, because it's |
| 207 | # the job of a later step (rstrip_ws) to remove it -- |
| 208 | # and if rstrip_ws is false, we'd better preserve it! |
| 209 | # (NB. this means that if the final line is all comment |
| 210 | # and has no trailing newline, we will think that it's |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 211 | # EOF; I think that's OK.) |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 212 | eol = (line[-1] == '\n') and '\n' or '' |
| 213 | line = line[0:pos] + eol |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 214 | |
| 215 | else: # it's an escaped "#" |
| 216 | line = string.replace (line, "\\#", "#") |
| 217 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 218 | |
| 219 | # did previous line end with a backslash? then accumulate |
| 220 | if self.join_lines and buildup_line: |
| 221 | # oops: end of file |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 222 | if line is None: |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 223 | self.warn ("continuation line immediately precedes " |
| 224 | "end-of-file") |
| 225 | return buildup_line |
| 226 | |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 227 | if self.collapse_join: |
| 228 | line = string.lstrip (line) |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 229 | line = buildup_line + line |
| 230 | |
| 231 | # careful: pay attention to line number when incrementing it |
| 232 | if type (self.current_line) is ListType: |
| 233 | self.current_line[1] = self.current_line[1] + 1 |
| 234 | else: |
| 235 | self.current_line = [self.current_line, self.current_line+1] |
| 236 | # just an ordinary line, read it as usual |
| 237 | else: |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 238 | if line is None: # eof |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 239 | return None |
| 240 | |
| 241 | # still have to be careful about incrementing the line number! |
| 242 | if type (self.current_line) is ListType: |
| 243 | self.current_line = self.current_line[1] + 1 |
| 244 | else: |
| 245 | self.current_line = self.current_line + 1 |
Greg Ward | 91c488c | 1999-03-29 18:01:49 +0000 | [diff] [blame] | 246 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 247 | |
| 248 | # strip whitespace however the client wants (leading and |
| 249 | # trailing, or one or the other, or neither) |
| 250 | if self.lstrip_ws and self.rstrip_ws: |
| 251 | line = string.strip (line) |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 252 | elif self.lstrip_ws: |
| 253 | line = string.lstrip (line) |
| 254 | elif self.rstrip_ws: |
| 255 | line = string.rstrip (line) |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 256 | |
| 257 | # blank line (whether we rstrip'ed or not)? skip to next line |
| 258 | # if appropriate |
Greg Ward | 3d05c16 | 2000-09-16 18:09:22 +0000 | [diff] [blame^] | 259 | if (line == '' or line == '\n') and self.skip_blanks: |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 260 | continue |
| 261 | |
| 262 | if self.join_lines: |
| 263 | if line[-1] == '\\': |
| 264 | buildup_line = line[:-1] |
| 265 | continue |
| 266 | |
| 267 | if line[-2:] == '\\\n': |
| 268 | buildup_line = line[0:-2] + '\n' |
| 269 | continue |
| 270 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 271 | # well, I guess there's some actual content there: return it |
| 272 | return line |
| 273 | |
| 274 | # end readline |
| 275 | |
| 276 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 277 | def readlines (self): |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 278 | """Read and return the list of all logical lines remaining in the |
| 279 | current file.""" |
| 280 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 281 | lines = [] |
| 282 | while 1: |
| 283 | line = self.readline() |
| 284 | if line is None: |
| 285 | return lines |
| 286 | lines.append (line) |
| 287 | |
| 288 | |
Greg Ward | 91c488c | 1999-03-29 18:01:49 +0000 | [diff] [blame] | 289 | def unreadline (self, line): |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 290 | """Push 'line' (a string) onto an internal buffer that will be |
| 291 | checked by future 'readline()' calls. Handy for implementing |
| 292 | a parser with line-at-a-time lookahead.""" |
| 293 | |
Greg Ward | 91c488c | 1999-03-29 18:01:49 +0000 | [diff] [blame] | 294 | self.linebuf.append (line) |
| 295 | |
| 296 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 297 | if __name__ == "__main__": |
| 298 | test_data = """# test file |
| 299 | |
| 300 | line 3 \\ |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 301 | continues on next line |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 302 | """ |
| 303 | |
Greg Ward | 274ad9d | 1999-09-29 13:03:32 +0000 | [diff] [blame] | 304 | |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 305 | # result 1: no fancy options |
| 306 | result1 = map (lambda x: x + "\n", string.split (test_data, "\n")[0:-1]) |
| 307 | |
| 308 | # result 2: just strip comments |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 309 | result2 = ["\n", "\n", "line 3 \\\n", " continues on next line\n"] |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 310 | |
| 311 | # result 3: just strip blank lines |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 312 | result3 = ["# test file\n", "line 3 \\\n", " continues on next line\n"] |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 313 | |
| 314 | # result 4: default, strip comments, blank lines, and trailing whitespace |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 315 | result4 = ["line 3 \\", " continues on next line"] |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 316 | |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 317 | # result 5: strip comments and blanks, plus join lines (but don't |
| 318 | # "collapse" joined lines |
| 319 | result5 = ["line 3 continues on next line"] |
| 320 | |
| 321 | # result 6: strip comments and blanks, plus join lines (and |
| 322 | # "collapse" joined lines |
| 323 | result6 = ["line 3 continues on next line"] |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 324 | |
| 325 | def test_input (count, description, file, expected_result): |
| 326 | result = file.readlines () |
| 327 | # result = string.join (result, '') |
| 328 | if result == expected_result: |
| 329 | print "ok %d (%s)" % (count, description) |
| 330 | else: |
| 331 | print "not ok %d (%s):" % (count, description) |
| 332 | print "** expected:" |
| 333 | print expected_result |
| 334 | print "** received:" |
| 335 | print result |
| 336 | |
| 337 | |
| 338 | filename = "test.txt" |
| 339 | out_file = open (filename, "w") |
| 340 | out_file.write (test_data) |
| 341 | out_file.close () |
| 342 | |
| 343 | in_file = TextFile (filename, strip_comments=0, skip_blanks=0, |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 344 | lstrip_ws=0, rstrip_ws=0) |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 345 | test_input (1, "no processing", in_file, result1) |
| 346 | |
| 347 | in_file = TextFile (filename, strip_comments=1, skip_blanks=0, |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 348 | lstrip_ws=0, rstrip_ws=0) |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 349 | test_input (2, "strip comments", in_file, result2) |
| 350 | |
| 351 | in_file = TextFile (filename, strip_comments=0, skip_blanks=1, |
Greg Ward | abc2f96 | 1999-08-10 20:09:38 +0000 | [diff] [blame] | 352 | lstrip_ws=0, rstrip_ws=0) |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 353 | test_input (3, "strip blanks", in_file, result3) |
| 354 | |
| 355 | in_file = TextFile (filename) |
| 356 | test_input (4, "default processing", in_file, result4) |
| 357 | |
| 358 | in_file = TextFile (filename, strip_comments=1, skip_blanks=1, |
| 359 | join_lines=1, rstrip_ws=1) |
Greg Ward | 60cd286 | 2000-09-16 18:04:55 +0000 | [diff] [blame] | 360 | test_input (5, "join lines without collapsing", in_file, result5) |
| 361 | |
| 362 | in_file = TextFile (filename, strip_comments=1, skip_blanks=1, |
| 363 | join_lines=1, rstrip_ws=1, collapse_join=1) |
| 364 | test_input (6, "join lines with collapsing", in_file, result6) |
Greg Ward | d1dc475 | 1999-01-13 16:12:04 +0000 | [diff] [blame] | 365 | |
| 366 | os.remove (filename) |
| 367 | |