def tmpl_tags(self): "Scan template files and return template tags" keys = [] sdir = '%s/%s' % (self.tdir, self.tmpl) for name in os.listdir(sdir): if name[-1] == '~': continue if name == 'CVS': continue fname = os.path.join(sdir, name) with open(fname, 'r') as stream: for line in stream.readlines(): if line.find('__') != -1: # possible key keys += [k for k in parse_word(line)] return set(keys)
def test_parse_word(self): "Test parse_word function" sts = "sdlkfj __class__::Bla" result = parse_word(sts) expect = set(["__class__"]) self.assertEqual(expect, result)