def _parse_theme_file(self, f): contents = {} for line in f: # regex matching is easier by stripping leading/trailing whitespace line = line.strip() if Xparser.valid(line): # try matchig a line with rgb values match = Xparser.rgb(line) if match: contents[match['name']] = match['value'] continue # rgb match failed, try with hex match = Xparser.hex(line) if match: contents[match['name']] = match['value'] return contents
def test_urxvt_dot_rgb(self): line = "URxvt.color5: rgb:aa/bb/cc" self.assertTrue(Xparser.valid(line)) output = Xparser.rgb(line) self.assertEqual(output, self.expected)
def test_generic_rgb(self): line = "*color5: rgb:aa/bb/cc" self.assertTrue(Xparser.valid(line)) output = Xparser.rgb(line) self.assertEqual(output, self.expected)