def readVersionCookie(self, filename): f = codecs.open(filename, "r", "utf-8") currentText = f.read() # must read the whole thing to avoid reading # half a comment...optimize here, or hope the # disk cache gets used. if self.options.outFile: currentText = util.scrubText(currentText) trees = currentText.strip().split("\n\n") vc = trees[0] self.versionCookie = "" if vc[0:10] == "( (VERSION": self.versionCookie = vc
def readTrees(self, fileName, text=None): if text: currentText = text else: f = codecs.open(fileName, "r", "utf-8") currentText = f.read() if self.options.outFile: currentText = util.scrubText(currentText) trees = currentText.strip().split("\n\n") vc = trees[0] self.versionCookie = "" if vc[0:10] == "( (VERSION": self.versionCookie = vc trees = trees[1:] return trees
def test_scrubText(self): text = """ foo bar /* foo bar */ /~* foo bar *~/ <+ foo bar +> """.strip() self.assertMultiLineEqual(util.scrubText(text), "foo bar\n\n") bad_text = """ /* foo bar """ self.assertRaises(util.AnnotaldException, util.scrubText, bad_text)