quote still needed

This commit is contained in:
Martin Diehl 2020-03-03 12:32:38 +01:00
parent b1f21b189b
commit 1f3d5099cf
1 changed files with 11 additions and 3 deletions

View File

@ -63,6 +63,14 @@ class ASCIItable():
except AttributeError:
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,
dismiss = False):
@ -153,7 +161,7 @@ class ASCIItable():
head = ['{}\theader'.format(len(self.info)+self.__IO__['labeled'])] if header else []
head.append(self.info)
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.')
return self.output_write(head)
@ -422,9 +430,9 @@ class ASCIItable():
if len(self.data) == 0: return True
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:
return self.output_write( delimiter.join(self.data))
return self.output_write( delimiter.join(map(self._quote,self.data)))
# ------------------------------------------------------------------
def data_writeArray(self,