improved STDOUT | STDIN constructs -- no more broken pipe left-overs (I hope)
This commit is contained in:
parent
c24f258eba
commit
58fdf4ebfc
|
@ -43,13 +43,18 @@ class ASCIItable():
|
||||||
for item in what: self.output_write(item)
|
for item in what: self.output_write(item)
|
||||||
else:
|
else:
|
||||||
self.__IO__['output'] += [str(what)]
|
self.__IO__['output'] += [str(what)]
|
||||||
self.__IO__['buffered'] or self.output_flush()
|
return self.__IO__['buffered'] or self.output_flush()
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def output_flush(self,
|
def output_flush(self,
|
||||||
clear = True):
|
clear = True):
|
||||||
|
import sys
|
||||||
|
try:
|
||||||
self.__IO__['output'] == [] or self.__IO__['out'].write('\n'.join(self.__IO__['output']) + '\n')
|
self.__IO__['output'] == [] or self.__IO__['out'].write('\n'.join(self.__IO__['output']) + '\n')
|
||||||
|
except IOError, e:
|
||||||
|
return False
|
||||||
if clear: self.output_clear()
|
if clear: self.output_clear()
|
||||||
|
return True
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def output_clear(self):
|
def output_clear(self):
|
||||||
|
@ -84,7 +89,7 @@ class ASCIItable():
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def head_write(self):
|
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,
|
self.info,
|
||||||
'\t'.join(self.labels)])
|
'\t'.join(self.labels)])
|
||||||
|
|
||||||
|
@ -118,9 +123,9 @@ class ASCIItable():
|
||||||
def data_write(self):
|
def data_write(self):
|
||||||
if len(self.data) == 0: return
|
if len(self.data) == 0: return
|
||||||
if isinstance(self.data[0],list):
|
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:
|
else:
|
||||||
self.output_write ('\t'.join(map(str,self.data)))
|
return self.output_write ('\t'.join(map(str,self.data)))
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def data_append(self,
|
def data_append(self,
|
||||||
|
|
Loading…
Reference in New Issue