quote still needed
This commit is contained in:
parent
b1f21b189b
commit
1f3d5099cf
|
@ -63,6 +63,14 @@ class ASCIItable():
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return str(string)
|
return str(string)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
def _quote(self,
|
||||||
|
what):
|
||||||
|
"""Quote empty or white space-containing output."""
|
||||||
|
return '{quote}{content}{quote}'.format(
|
||||||
|
quote = ('"' if str(what)=='' or re.search(r"\s",str(what)) else ''),
|
||||||
|
content = what)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def close(self,
|
def close(self,
|
||||||
dismiss = False):
|
dismiss = False):
|
||||||
|
@ -153,7 +161,7 @@ class ASCIItable():
|
||||||
head = ['{}\theader'.format(len(self.info)+self.__IO__['labeled'])] if header else []
|
head = ['{}\theader'.format(len(self.info)+self.__IO__['labeled'])] if header else []
|
||||||
head.append(self.info)
|
head.append(self.info)
|
||||||
if self.__IO__['labeled']:
|
if self.__IO__['labeled']:
|
||||||
head.append('\t'.join(self.tags))
|
head.append('\t'.join(map(self._quote,self.tags)))
|
||||||
if len(self.tags) == 0: raise ValueError('no labels present.')
|
if len(self.tags) == 0: raise ValueError('no labels present.')
|
||||||
|
|
||||||
return self.output_write(head)
|
return self.output_write(head)
|
||||||
|
@ -422,9 +430,9 @@ class ASCIItable():
|
||||||
if len(self.data) == 0: return True
|
if len(self.data) == 0: return True
|
||||||
|
|
||||||
if isinstance(self.data[0],list):
|
if isinstance(self.data[0],list):
|
||||||
return self.output_write([delimiter.join(items) for items in self.data])
|
return self.output_write([delimiter.join(map(self._quote,items)) for items in self.data])
|
||||||
else:
|
else:
|
||||||
return self.output_write( delimiter.join(self.data))
|
return self.output_write( delimiter.join(map(self._quote,self.data)))
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def data_writeArray(self,
|
def data_writeArray(self,
|
||||||
|
|
Loading…
Reference in New Issue