(self)
Parse the color scheme.
Parse the color scheme.
Parse the color scheme .
def parse_scheme(self):
        """Parse the color scheme."""

        variables = self.scheme_obj.get('variables', {})
        for k, v in variables.items():
            m = COLOR_RE.match(v.strip())
            var = translate_color(m, self.variables, self.scheme_obj.get('variables')) if m is not None else ""
            if var is None:
                var = ""
            self.variables[k] = var
            variables[k] = var

        global_options = self.scheme_obj[GLOBAL_OPTIONS]
        for k, v in global_options.items():
            m = COLOR_RE.match(v.strip())
            if m is not None:
                global_color = translate_color(m, self.variables, {})
                if global_color is not None:
                    global_options[k] = global_color

        # Create scope colors mapping from color scheme file
        for item in self.scheme_obj["rules"]:
            if item.get('scope', None) is not None:
                # Foreground color
                color = item.get('foreground', None)
                if isinstance(color, list):
                    # Hashed Syntax Highlighting
                    for index, c in enumerate(color):
                        color[index] = translate_color(COLOR_RE.match(c.strip()), self.variables, {})
                elif isinstance(color, str):
                    item['foreground'] = translate_color(COLOR_RE.match(color.strip()), self.variables, {})
                # Background color
                bgcolor = item.get('background', None)
                if isinstance(bgcolor, str):
                    item['background'] = translate_color(COLOR_RE.match(bgcolor.strip()), self.variables, {})
                # Selection foreground color
                scolor = item.get('selection_foreground', None)
                if isinstance(scolor, str):
                    item['selection_foreground'] = translate_color(COLOR_RE.match(scolor.strip()), self.variables, {})
def parse_scheme ( self ) : variables = self . scheme_obj . get ( 'variables' , { } ) for k , v in variables . items ( ) : m = COLOR_RE . match ( v . strip ( ) ) var = translate_color ( m , self . variables , self . scheme_obj . get ( 'variables' ) ) if m is not None else "" if var is None : var = "" self . variables [ k ] = var variables [ k ] = var global_options = self . scheme_obj [ GLOBAL_OPTIONS ] for k , v in global_options . items ( ) : m = COLOR_RE . match ( v . strip ( ) ) if m is not None : global_color = translate_color ( m , self . variables , { } ) if global_color is not None : global_options [ k ] = global_color # Create scope colors mapping from color scheme file for item in self . scheme_obj [ "rules" ] : if item . get ( 'scope' , None ) is not None : # Foreground color color = item . get ( 'foreground' , None ) if isinstance ( color , list ) : # Hashed Syntax Highlighting for index , c in enumerate ( color ) : color [ index ] = translate_color ( COLOR_RE . match ( c . strip ( ) ) , self . variables , { } ) elif isinstance ( color , str ) : item [ 'foreground' ] = translate_color ( COLOR_RE . match ( color . strip ( ) ) , self . variables , { } ) # Background color bgcolor = item . get ( 'background' , None ) if isinstance ( bgcolor , str ) : item [ 'background' ] = translate_color ( COLOR_RE . match ( bgcolor . strip ( ) ) , self . variables , { } ) # Selection foreground color scolor = item . get ( 'selection_foreground' , None ) if isinstance ( scolor , str ) : item [ 'selection_foreground' ] = translate_color ( COLOR_RE . match ( scolor . strip ( ) ) , self . variables , { } )