Lines Matching refs:file
11 """Provides a file-like object that takes care of all the things you
12 commonly want to do when processing a text file that has some
26 TextFile (filename=None, file=None, **options)
28 It bombs (RuntimeError) if both 'filename' and 'file' are None;
29 'filename' should be a string, and 'file' a file object (or
32 can include it in warning messages. If 'file' is not supplied,
60 error handler used to decode the file content
63 semantics of 'readline()' must differ from those of the builtin file
65 None for end-of-file: an empty string might just be a blank line (or
78 def __init__(self, filename=None, file=None, **options):
80 (a string) and 'file' (a file-like object) must be supplied.
83 if filename is None and file is None:
84 raise RuntimeError("you must supply either or both of 'filename' and 'file'")
99 if file is None:
103 self.file = file
104 self.current_line = 0 # assuming that file is at BOF!
107 # actually read from the file; it's only populated by an
112 """Open a new file named 'filename'. This overrides both the
113 'filename' and 'file' arguments to the constructor."""
115 self.file = io.open(self.filename, 'r', errors=self.errors)
119 """Close the current file and forget everything we know about it
121 file = self.file
122 self.file = None
125 file.close()
144 line in the current file. If the current logical line in the
145 file spans multiple physical lines, the warning refers to the
153 """Read and return a single logical line from the current file (or
159 line(s) just read. Returns None on end-of-file, since the empty
175 line = self.file.readline()
219 # oops: end of file
222 "end-of-file")
274 current file."""