(path=COLOUR_FILE)
return {'Colours': colours, 'Maps': colour_maps}
Read the colours text file to get all the data.
    
    Returns a dictionary containing the keys 'Colours' and 'Maps'.
    
    Colours:
        Syntax: colour.name=value
        The value must be given as a hex code, where it will be converted 
        into an RGBA list with the range of 0 to 255.
        
        Format:
            {name.lower(): {'UpperCase': name, 
                            'Colour': [r, 
                                       g, 
                                       b,
                                       a]}}
            
    Maps:
        Syntax: maps.name.type[.options]=value
        
        Set a colour scheme for a map with "maps.Name.colour=__________".
        That will add a colour map that can be accessed with "Name".
        Add alternative options with "maps.Name.colour.Alter.native=__________"
        That will add a colour map that can be accessed with "nativeAlterName".
        Set if it is allowed for tracks, clicks, or the keyboard 
        with "maps.Name.tracks/clicks/keyboard=True".
        It may be enabled for more than one.
        
        Format:
            {name.lower(): {'Colour': value,
                            'UpperCase': name,
                            'Type': {'tracks': bool,
                                     'clicks': bool,
                                     'keyboard': bool}}}
Read the colours text file to get all the data.
    
    Returns a dictionary containing the keys 'Colours' and 'Maps'.
    
    Colours:
        Syntax: colour.name=value
        The value must be given as a hex code, where it will be converted 
        into an RGBA list with the range of 0 to 255.
        
        Format:
            {name.lower(): {'UpperCase': name, 
                            'Colour': [r, 
                                       g, 
                                       b,
                                       a]}}
            
    Maps:
        Syntax: maps.name.type[.options]=value
        
        Set a colour scheme for a map with "maps.Name.colour=__________".
        That will add a colour map that can be accessed with "Name".
        Add alternative options with "maps.Name.colour.Alter.native=__________"
        That will add a colour map that can be accessed with "nativeAlterName".
        Set if it is allowed for tracks, clicks, or the keyboard 
        with "maps.Name.tracks/clicks/keyboard=True".
        It may be enabled for more than one.
        
        Format:
            {name.lower(): {'Colour': value,
                            'UpperCase': name,
                            'Type': {'tracks': bool,
                                     'clicks': bool,
                                     'keyboard': bool}}}
Read the colours text file to get all the data . Returns a dictionary containing the keys Colours and Maps . Colours : Syntax : colour . name = value The value must be given as a hex code where it will be converted into an RGBA list with the range of 0 to 255 . Format : { name . lower () : { UpperCase : name Colour : [ r g b a ] }} Maps : Syntax : maps . name . type [ . options ] = value Set a colour scheme for a map with maps . Name . colour = __________ . That will add a colour map that can be accessed with Name . Add alternative options with maps . Name . colour . Alter . native = __________ That will add a colour map that can be accessed with nativeAlterName . Set if it is allowed for tracks clicks or the keyboard with maps . Name . tracks / clicks / keyboard = True . It may be enabled for more than one . Format : { name . lower () : { Colour : value UpperCase : name Type : { tracks : bool clicks : bool keyboard : bool }}}
def parse_colour_file(path=COLOUR_FILE):
    """Read the colours text file to get all the data.
    
    Returns a dictionary containing the keys 'Colours' and 'Maps'.
    
    Colours:
        Syntax: colour.name=value
        The value must be given as a hex code, where it will be converted 
        into an RGBA list with the range of 0 to 255.
        
        Format:
            {name.lower(): {'UpperCase': name, 
                            'Colour': [r, 
                                       g, 
                                       b,
                                       a]}}
            
    Maps:
        Syntax: maps.name.type[.options]=value
        
        Set a colour scheme for a map with "maps.Name.colour=__________".
        That will add a colour map that can be accessed with "Name".
        Add alternative options with "maps.Name.colour.Alter.native=__________"
        That will add a colour map that can be accessed with "nativeAlterName".
        Set if it is allowed for tracks, clicks, or the keyboard 
        with "maps.Name.tracks/clicks/keyboard=True".
        It may be enabled for more than one.
        
        Format:
            {name.lower(): {'Colour': value,
                            'UpperCase': name,
                            'Type': {'tracks': bool,
                                     'clicks': bool,
                                     'keyboard': bool}}}
    """
    with TextFile(path, 'r') as f:
        data = f.read()
    
    colours = {}
    colour_maps = {}
    for i, line in enumerate(data.splitlines()):
        var, value = [i.strip() for i in line.split('=', 1)]
        var_parts = var.split('.')
        
        #Parse colour part
        if var_parts[0] == 'colour':
            if len(var_parts) < 2:
                continue
                
            rgb = tuple(hex_to_colour(value)[1])
            if rgb is not None:
                colours[format_name(var_parts[1])] = {'Uppercase': var_parts[1], 'Colour': rgb}
        
        #Parse colour map part
        elif var_parts[0] == 'map':
            if len(var_parts) < 3:
                continue
        
            map_name = var_parts[1]
            map_name_l = format_name(map_name)
            var_type = var_parts[2].lower()
            
            if map_name_l not in colour_maps:
                colour_maps[map_name_l] = {'Colour': None, 'UpperCase': map_name,
                                         'Type': {'tracks': False, 'clicks': False, 'keyboard': False}}
                                         
            if var_type == 'colour':
            
                #Check if it is an alternative map, and if so, link to the main one
                map_name_ext = ''.join(var_parts[3:][::-1]) + map_name
                map_name_ext_l = format_name(map_name_ext)
                if map_name_l != map_name_ext_l:
                    colour_maps[map_name_ext_l] = {'Colour': value, 'UpperCase': map_name_ext,
                                                   'Type': colour_maps[map_name_l]['Type']}
                else:
                    colour_maps[map_name_ext_l]['Colour'] = value
                    
            elif var_type in ('clicks', 'tracks', 'keyboard'):
                if value.lower().startswith('t') or value.lower().startswith('y'):
                    colour_maps[map_name_l]['Type'][var_type] = True
                    
    return {'Colours': colours, 'Maps': colour_maps}
def parse_colour_file ( path = COLOUR_FILE ) : with TextFile ( path , 'r' ) as f : data = f . read ( ) colours = { } colour_maps = { } for i , line in enumerate ( data . splitlines ( ) ) : var , value = [ i . strip ( ) for i in line . split ( '=' , 1 ) ] var_parts = var . split ( '.' ) #Parse colour part if var_parts [ 0 ] == 'colour' : if len ( var_parts ) < 2 : continue rgb = tuple ( hex_to_colour ( value ) [ 1 ] ) if rgb is not None : colours [ format_name ( var_parts [ 1 ] ) ] = { 'Uppercase' : var_parts [ 1 ] , 'Colour' : rgb } #Parse colour map part elif var_parts [ 0 ] == 'map' : if len ( var_parts ) < 3 : continue map_name = var_parts [ 1 ] map_name_l = format_name ( map_name ) var_type = var_parts [ 2 ] . lower ( ) if map_name_l not in colour_maps : colour_maps [ map_name_l ] = { 'Colour' : None , 'UpperCase' : map_name , 'Type' : { 'tracks' : False , 'clicks' : False , 'keyboard' : False } } if var_type == 'colour' : #Check if it is an alternative map, and if so, link to the main one map_name_ext = '' . join ( var_parts [ 3 : ] [ : : - 1 ] ) + map_name map_name_ext_l = format_name ( map_name_ext ) if map_name_l != map_name_ext_l : colour_maps [ map_name_ext_l ] = { 'Colour' : value , 'UpperCase' : map_name_ext , 'Type' : colour_maps [ map_name_l ] [ 'Type' ] } else : colour_maps [ map_name_ext_l ] [ 'Colour' ] = value elif var_type in ( 'clicks' , 'tracks' , 'keyboard' ) : if value . lower ( ) . startswith ( 't' ) or value . lower ( ) . startswith ( 'y' ) : colour_maps [ map_name_l ] [ 'Type' ] [ var_type ] = True return { 'Colours' : colours , 'Maps' : colour_maps }