Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 5
0
 def test_generic_hex(self):
     line = "*color5: #aabbcc"
     self.assertTrue(Xparser.valid(line))
     output = Xparser.hex(line)
     self.assertEqual(output, self.expected)
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 11
0
 def test_generic_hex(self):
     line = "*color5: #aabbcc"
     self.assertTrue(Xparser.valid(line))
     output = Xparser.hex(line)
     self.assertEqual(output, self.expected)
Exemplo n.º 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)