DebugClients/Python3/AsyncFile.py

changeset 1213
5d4e67e59ed3
parent 945
8cd4d08fa9f6
child 1509
c0b5e693b0eb
diff -r 058fc9ffb0d9 -r 5d4e67e59ed3 DebugClients/Python3/AsyncFile.py
--- a/DebugClients/Python3/AsyncFile.py	Tue Aug 16 15:52:12 2011 +0200
+++ b/DebugClients/Python3/AsyncFile.py	Tue Aug 16 17:01:46 2011 +0200
@@ -43,11 +43,15 @@
         @param name name of this file (string)
         """
         # Initialise the attributes.
-        self.__closed = False
+        self.closed = False
         self.sock = sock
         self.mode = mode
         self.name = name
         self.nWriteErrors = 0
+        
+        self.encoding = "utf-8"
+        self.line_buffering = True
+        self.errors = None
 
         self.wpending = ''
 
@@ -98,10 +102,10 @@
         
         @param closeit flag to indicate a close ordered by the debugger code (boolean)
         """
-        if closeit and not self.__closed:
+        if closeit and not self.closed:
             self.flush()
             self.sock.close()
-            self.__closed = True
+            self.closed = True
 
     def flush(self):
         """
@@ -128,6 +132,14 @@
         except socket.error:
             return -1
 
+    def readable(self):
+        """
+        Public method to check, if the stream is readable.
+        
+        @return flag indicating a readable stream (boolean)
+        """
+        return self.mode == "r"
+    
     def read_p(self, size=-1):
         """
         Public method to read bytes from this file.
@@ -230,6 +242,14 @@
             line = line[:sizehint]
         return line
     
+    def seekable(self):
+        """
+        Public method to check, if the stream is seekable.
+        
+        @return flag indicating a seekable stream (boolean)
+        """
+        return False
+    
     def seek(self, offset, whence=0):
         """
         Public method to move the filepointer.
@@ -260,6 +280,14 @@
         """
         raise IOError((29, '[Errno 29] Illegal seek'))
 
+    def writable(self):
+        """
+        Public method to check, if a stream is writable.
+        
+        @return flag indicating a writable stream (boolean)
+        """
+        return self.mode == "w"
+    
     def write(self, s):
         """
         Public method to write a string to the file.

eric ide

mercurial