mailr7857 - /branches/multi_processor_merge/multi/prependStringIO.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 20, 2008 - 21:27:
Author: bugman
Date: Mon Oct 20 21:27:28 2008
New Revision: 7857

URL: http://svn.gna.org/viewcvs/relax?rev=7857&view=rev
Log:
Alphabetical sorting of class methods.


Modified:
    branches/multi_processor_merge/multi/prependStringIO.py

Modified: branches/multi_processor_merge/multi/prependStringIO.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/multi/prependStringIO.py?rev=7857&r1=7856&r2=7857&view=diff
==============================================================================
--- branches/multi_processor_merge/multi/prependStringIO.py (original)
+++ branches/multi_processor_merge/multi/prependStringIO.py Mon Oct 20 
21:27:28 2008
@@ -32,26 +32,13 @@
         self.thread_stream_map = {}
 
 
-    def current_thread_id(self):
-        return self.thread_id(currentThread())
-
-
-    def thread_id(self, thread):
-        # wanted to use thread.get_ident but main thread barfes on it could 
use -1?
-        return id(thread)
-
-
     def add_stream(self, stream):
         thread_id = self.current_thread_id()
         self.thread_stream_map[thread_id] = stream
 
 
-    def write(self, string):
-        thread = currentThread()
-        thread_id = self.thread_id(thread)
-
-        stream = self.thread_stream_map[thread_id]
-        return stream.write(string)
+    def current_thread_id(self):
+        return self.thread_id(currentThread())
 
 
     def get_stream(self, thread=None):
@@ -67,6 +54,19 @@
         return self.get_stream().getvalue()
 
 
+    def thread_id(self, thread):
+        # wanted to use thread.get_ident but main thread barfes on it could 
use -1?
+        return id(thread)
+
+
+    def write(self, string):
+        thread = currentThread()
+        thread_id = self.thread_id(thread)
+
+        stream = self.thread_stream_map[thread_id]
+        return stream.write(string)
+
+
 #FIXME could these two classes be merged via use of a target stream and 
multiple inheritance?
 class PrependOut(StringIO):
     def __init__(self, token, stream):
@@ -76,6 +76,17 @@
         self.first_time = True
 
         self.stream = stream
+
+
+#    def flush(self):
+#        self.stream.write(self.getvalue().rstrip(self.token))
+#        self.truncate(0)
+#        self.first_time = True
+
+
+    # lost more functions needed use dict???
+    def isatty(self, *args, **kwargs):
+        return stream.isatty(*args, **kwargs)
 
 
     def write(self, string):
@@ -92,17 +103,6 @@
         #self.truncate(0)
 
 
-    # lost more functions needed use dict???
-    def isatty(self, *args, **kwargs):
-        return stream.isatty(*args, **kwargs)
-
-
-#    def flush(self):
-#        self.stream.write(self.getvalue().rstrip(self.token))
-#        self.truncate(0)
-#        self.first_time = True
-
-
 #TODO: maybe this hsould be a delegate to a stringio rather than being a 
stringio as this will speed things up and simplify things
 class PrependStringIO(StringIO):
     def __init__(self, token, target_stream=None):
@@ -116,6 +116,22 @@
             self.target_stream = target_stream
 
 
+    def getvalue(self):
+        result = StringIO.getvalue(self)
+        if len(result) > 0 and result[-1] == '\n':
+           result = result[0:-self.token_length-1]
+           result = result+'\n'
+
+        return result
+
+
+    def truncate(self, size=None):
+        if size == 0:
+           self.first_time = True
+        #PY3K: should be a call to super but StringIO is a old style class
+        StringIO.truncate(self, size)
+
+
     def write(self, string):
         # FIXME: raising an exception here wedges mpi4py
 
@@ -127,21 +143,6 @@
         StringIO.write(self.target_stream, string)
 
 
-    def truncate(self, size=None):
-        if size == 0:
-           self.first_time = True
-        #PY3K: should be a call to super but StringIO is a old style class
-        StringIO.truncate(self, size)
-
-
-    def getvalue(self):
-        result = StringIO.getvalue(self)
-        if len(result) > 0 and result[-1] == '\n':
-           result = result[0:-self.token_length-1]
-           result = result+'\n'
-
-        return result
-
 if __name__ == '__main__':
     prepend = PrependStringIO('>001 | ')
 




Related Messages


Powered by MHonArc, Updated Mon Oct 20 21:40:04 2008