def __init__(self, st): self.finallst = [] self.commentbin = [] self.wordbin = [] sep = ";" linesep = mylib3.getlinesep(st) st = "dummy;" + linesep + st # the first command is skipped (comment, word, rest) = self.commentwordrest(st, sep, linesep) self.commentbin.append(comment) self.wordbin.append(word) while rest != None: rest = self.commasemifinish(rest, linesep)
def removecomment(st,c): # the comment is similar to that in python. # any charachter after the # is treated as a comment # until the end of the line # st is the string to be de-commented # c is the comment phrase linesep=mylib3.getlinesep(st) ls=st.split(linesep) for i in range(len(ls)): l=ls[i].split(c) ls[i]=l[0] return string.join(ls,linesep)
def __init__(self, st): linesep = mylib3.getlinesep(st) self.linesep = linesep nocom = nocomment(st) iddst = nocom.nocom.strip() st = self.removecommasemi(iddst) # b=eplus1.ordereddict() while st.find(";") != -1: (command, this, rest) = self.commandthisrest(st) st = rest self.add(command, this) self.reverse()
def removeblanklines(st): """ removeblanklines(st) returns the string after remove blank lines in 'st' """ linesep=mylib3.getlinesep(st) ls=st.split(linesep) lss=[] for el in ls: ell=el.strip() if ell!='': lss.append(el) st1=linesep.join(lss) return st1
def stripcomments(self, text): lsep = mylib3.getlinesep(text) ls = string.split(text, lsep) for i in range(len(ls)): ls[i] = self.striplinecomments(ls[i]) return string.join(ls, lsep)