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