--- a/colours.py Mon Jun 24 19:21:49 2019 +0300 +++ b/colours.py Thu Aug 26 19:16:25 2021 +0300 @@ -15,10 +15,7 @@ else: return str(self.index) def __repr__(self): - try: - return 'colours.' + colours_inverse_dict[self.index] - except KeyError: - return str.format('Colour({!r})', self.index) + return str.format('Colour({!r})', self.index) @property def is_direct_colour(self): return self.index >= 0x2000000 @@ -98,15 +95,7 @@ colour = parse_ldconfig_ldr_line(line) yield (colour['code'], colour) -class colours: - ''' - LDConfig colour namespace, exists for interactive mode and for - Colour.__repr__ to return something pretty. - ''' - pass - -# LDConfig lookup tables -colours_inverse_dict = {} +# LDConfig lookup table ldconfig_colour_data = {} def load_colours(ldconfig_ldr): @@ -115,13 +104,3 @@ ''' global ldconfig_colour_data ldconfig_colour_data = dict(parse_ldconfig_ldr(ldconfig_ldr)) - for index, colour in ldconfig_colour_data.items(): - identifier = colour['name'].replace(' ', '_').lower() - setattr(colours, identifier, Colour(index)) - colours_inverse_dict[index] = identifier - -# Interactive mode support (pass LDConfig.ldr path as a command-line argument) -if __name__ == '__main__': - from sys import argv - with open(argv[1]) as ldconfig_ldr: - load_colours(ldconfig_ldr)