added “.close()” method to close input and output at the same time.

accept header only if space present between number and “head” string.
This commit is contained in:
Philip Eisenlohr 2015-05-19 20:35:56 +00:00
parent b58cbe424d
commit 9f569d04c6
1 changed files with 5 additions and 1 deletions

View File

@ -43,6 +43,10 @@ class ASCIItable():
except:
return 0.0
# ------------------------------------------------------------------
def close(self):
return self.input_close() and self.output_close()
# ------------------------------------------------------------------
def input_close(self):
return self.__IO__['in'].close()
@ -93,7 +97,7 @@ class ASCIItable():
except:
pass
firstline = self.__IO__['in'].readline()
m = re.search('(\d+)\s*head', firstline.lower())
m = re.search('(\d+)\s+head', firstline.lower())
if self.__IO__['labels']: # table features labels
if m: # found header info
self.info = [self.__IO__['in'].readline().strip() for i in xrange(1,int(m.group(1)))]