Example #1
0
    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
Example #2
0
    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
Example #3
0
 def test_urxvt_dot_hex(self):
     line = "URxvt.color5: #aabbcc"
     self.assertTrue(Xparser.valid(line))
     output = Xparser.hex(line)
     self.assertEqual(output, self.expected)
Example #4
0
 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)
Example #5
0
 def test_generic_hex(self):
     line = "*color5: #aabbcc"
     self.assertTrue(Xparser.valid(line))
     output = Xparser.hex(line)
     self.assertEqual(output, self.expected)
Example #6
0
 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)
Example #7
0
 def test_comments(self):
     line = ";*color5: rgb:aa/bb/cc"
     self.assertFalse(Xparser.valid(line))
     line = "#*color5: rgb:aa/bb/cc"
     self.assertFalse(Xparser.valid(line))
Example #8
0
 def test_comments(self):
     line = ";*color5: rgb:aa/bb/cc"
     self.assertFalse(Xparser.valid(line))
     line = "#*color5: rgb:aa/bb/cc"
     self.assertFalse(Xparser.valid(line))
Example #9
0
 def test_urxvt_dot_hex(self):
     line = "URxvt.color5: #aabbcc"
     self.assertTrue(Xparser.valid(line))
     output = Xparser.hex(line)
     self.assertEqual(output, self.expected)
Example #10
0
 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)
Example #11
0
 def test_generic_hex(self):
     line = "*color5: #aabbcc"
     self.assertTrue(Xparser.valid(line))
     output = Xparser.hex(line)
     self.assertEqual(output, self.expected)
Example #12
0
 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)