improved STDOUT | STDIN constructs -- no more broken pipe left-overs (I hope)

This commit is contained in:
Philip Eisenlohr 2012-02-16 18:42:04 +00:00
parent c24f258eba
commit 58fdf4ebfc
1 changed files with 13 additions and 8 deletions

View File

@ -43,13 +43,18 @@ class ASCIItable():
for item in what: self.output_write(item)
else:
self.__IO__['output'] += [str(what)]
self.__IO__['buffered'] or self.output_flush()
return self.__IO__['buffered'] or self.output_flush()
# ------------------------------------------------------------------
def output_flush(self,
clear = True):
import sys
try:
self.__IO__['output'] == [] or self.__IO__['out'].write('\n'.join(self.__IO__['output']) + '\n')
except IOError, e:
return False
if clear: self.output_clear()
return True
# ------------------------------------------------------------------
def output_clear(self):
@ -84,7 +89,7 @@ class ASCIItable():
# ------------------------------------------------------------------
def head_write(self):
self.output_write (['%i\theader'%(len(self.info)+1),
return self.output_write (['%i\theader'%(len(self.info)+1),
self.info,
'\t'.join(self.labels)])
@ -118,9 +123,9 @@ class ASCIItable():
def data_write(self):
if len(self.data) == 0: return
if isinstance(self.data[0],list):
self.output_write (['\t'.join(map(str,items)) for items in self.data])
return self.output_write (['\t'.join(map(str,items)) for items in self.data])
else:
self.output_write ('\t'.join(map(str,self.data)))
return self.output_write ('\t'.join(map(str,self.data)))
# ------------------------------------------------------------------
def data_append(self,