remove CR and LF from labels and info lines. Can happen if multiline shell input is parsed...

This commit is contained in:
Philip Eisenlohr 2016-04-20 15:46:39 -04:00
parent 13e214fe18
commit 54dec3ea2a
1 changed files with 12 additions and 4 deletions

View File

@ -66,6 +66,14 @@ class ASCIItable():
except: except:
return 0.0 return 0.0
# ------------------------------------------------------------------
def _noCRLF(self,
string):
try:
return string.replace('\n','').replace('\r','')
except:
return string
# ------------------------------------------------------------------ # ------------------------------------------------------------------
def close(self, def close(self,
dismiss = False): dismiss = False):
@ -243,9 +251,9 @@ class ASCIItable():
try: try:
for item in what: self.labels_append(item) for item in what: self.labels_append(item)
except: except:
self.labels += [str(what)] self.labels += [self._noCRLF(str(what))]
else: else:
self.labels += [what] self.labels += [self._noCRLF(what)]
self.__IO__['labeled'] = True # switch on processing (in particular writing) of labels self.__IO__['labeled'] = True # switch on processing (in particular writing) of labels
if reset: self.__IO__['labels'] = list(self.labels) # subsequent data_read uses current labels as data size if reset: self.__IO__['labels'] = list(self.labels) # subsequent data_read uses current labels as data size
@ -372,9 +380,9 @@ class ASCIItable():
try: try:
for item in what: self.info_append(item) for item in what: self.info_append(item)
except: except:
self.info += [str(what)] self.info += [self._noCRLF(str(what))]
else: else:
self.info += [what] self.info += [self._noCRLF(what)]
# ------------------------------------------------------------------ # ------------------------------------------------------------------
def info_clear(self): def info_clear(self):