def clean_start(self, pat='[two|three|four]cols{(.*)'): obj0 = self.objlist[0] p = re.compile(pat) q = p.search(obj0.string) if q: self.objlist.pop(0) rest = q.group(1) if rest: line0 = line(rest) self.objlist.insert(0,line0)
def clean_end(self, pat='(.*)}'): end_obj = self.objlist[-1] p = re.compile(pat) q = p.match(end_obj.string) if q: self.objlist.pop() start = q.group(1) rest = q.group(1) if rest: lastline = line(rest) self.objlist.append(lastline)