41 @param sock the socket object being wrapped |
41 @param sock the socket object being wrapped |
42 @param mode mode of this file (string) |
42 @param mode mode of this file (string) |
43 @param name name of this file (string) |
43 @param name name of this file (string) |
44 """ |
44 """ |
45 # Initialise the attributes. |
45 # Initialise the attributes. |
46 self.__closed = False |
46 self.closed = False |
47 self.sock = sock |
47 self.sock = sock |
48 self.mode = mode |
48 self.mode = mode |
49 self.name = name |
49 self.name = name |
50 self.nWriteErrors = 0 |
50 self.nWriteErrors = 0 |
|
51 |
|
52 self.encoding = "utf-8" |
|
53 self.line_buffering = True |
|
54 self.errors = None |
51 |
55 |
52 self.wpending = '' |
56 self.wpending = '' |
53 |
57 |
54 def __checkMode(self, mode): |
58 def __checkMode(self, mode): |
55 """ |
59 """ |
126 try: |
130 try: |
127 return self.sock.fileno() |
131 return self.sock.fileno() |
128 except socket.error: |
132 except socket.error: |
129 return -1 |
133 return -1 |
130 |
134 |
|
135 def readable(self): |
|
136 """ |
|
137 Public method to check, if the stream is readable. |
|
138 |
|
139 @return flag indicating a readable stream (boolean) |
|
140 """ |
|
141 return self.mode == "r" |
|
142 |
131 def read_p(self, size=-1): |
143 def read_p(self, size=-1): |
132 """ |
144 """ |
133 Public method to read bytes from this file. |
145 Public method to read bytes from this file. |
134 |
146 |
135 @param size maximum number of bytes to be read (int) |
147 @param size maximum number of bytes to be read (int) |
228 line = input() + '\n' |
240 line = input() + '\n' |
229 if sizehint >= 0: |
241 if sizehint >= 0: |
230 line = line[:sizehint] |
242 line = line[:sizehint] |
231 return line |
243 return line |
232 |
244 |
|
245 def seekable(self): |
|
246 """ |
|
247 Public method to check, if the stream is seekable. |
|
248 |
|
249 @return flag indicating a seekable stream (boolean) |
|
250 """ |
|
251 return False |
|
252 |
233 def seek(self, offset, whence=0): |
253 def seek(self, offset, whence=0): |
234 """ |
254 """ |
235 Public method to move the filepointer. |
255 Public method to move the filepointer. |
236 |
256 |
237 @param offset offset to move the filepointer to (integer) |
257 @param offset offset to move the filepointer to (integer) |
258 @exception IOError This method is not supported and always raises an |
278 @exception IOError This method is not supported and always raises an |
259 IOError. |
279 IOError. |
260 """ |
280 """ |
261 raise IOError((29, '[Errno 29] Illegal seek')) |
281 raise IOError((29, '[Errno 29] Illegal seek')) |
262 |
282 |
|
283 def writable(self): |
|
284 """ |
|
285 Public method to check, if a stream is writable. |
|
286 |
|
287 @return flag indicating a writable stream (boolean) |
|
288 """ |
|
289 return self.mode == "w" |
|
290 |
263 def write(self, s): |
291 def write(self, s): |
264 """ |
292 """ |
265 Public method to write a string to the file. |
293 Public method to write a string to the file. |
266 |
294 |
267 @param s bytes to be written (string) |
295 @param s bytes to be written (string) |