(self, obj)
Convert tmTheme object to new format.
Convert tmTheme object to new format.
Convert tmTheme object to new format .
def convert_format(self, obj):
        """Convert tmTheme object to new format."""

        self.scheme_obj = {
            "variables": {},
            GLOBAL_OPTIONS: {},
            "rules": []
        }

        for k, v in obj.items():
            if k == "settings":
                continue
            self.scheme_obj[k] = v

        for item in obj["settings"]:
            if item.get('scope', None) is None and item.get('name', None) is None:
                for k, v in item["settings"].items():
                    self.scheme_obj[GLOBAL_OPTIONS][RE_CAMEL_CASE.sub(to_snake, k)] = v
            if 'settings' in item and item.get('scope') is not None:
                rule = {}
                name = item.get('name')
                if name is not None:
                    rule['name'] = name
                scope = item.get('scope')
                if scope is not None:
                    rule["scope"] = scope
                fg = item['settings'].get('foreground')
                if fg is not None:
                    rule['foreground'] = item['settings'].get('foreground')
                bg = item['settings'].get('background')
                if bg is not None:
                    rule['background'] = bg
                selfg = item["settings"].get("selectionForeground")
                if selfg is not None:
                    rule["selection_foreground"] = selfg
                font_style = item["settings"].get('fontStyle')
                if font_style is not None:
                    rule[FONT_STYLE] = font_style
                self.scheme_obj['rules'].append(rule)
def convert_format ( self , obj ) : self . scheme_obj = { "variables" : { } , GLOBAL_OPTIONS : { } , "rules" : [ ] } for k , v in obj . items ( ) : if k == "settings" : continue self . scheme_obj [ k ] = v for item in obj [ "settings" ] : if item . get ( 'scope' , None ) is None and item . get ( 'name' , None ) is None : for k , v in item [ "settings" ] . items ( ) : self . scheme_obj [ GLOBAL_OPTIONS ] [ RE_CAMEL_CASE . sub ( to_snake , k ) ] = v if 'settings' in item and item . get ( 'scope' ) is not None : rule = { } name = item . get ( 'name' ) if name is not None : rule [ 'name' ] = name scope = item . get ( 'scope' ) if scope is not None : rule [ "scope" ] = scope fg = item [ 'settings' ] . get ( 'foreground' ) if fg is not None : rule [ 'foreground' ] = item [ 'settings' ] . get ( 'foreground' ) bg = item [ 'settings' ] . get ( 'background' ) if bg is not None : rule [ 'background' ] = bg selfg = item [ "settings" ] . get ( "selectionForeground" ) if selfg is not None : rule [ "selection_foreground" ] = selfg font_style = item [ "settings" ] . get ( 'fontStyle' ) if font_style is not None : rule [ FONT_STYLE ] = font_style self . scheme_obj [ 'rules' ] . append ( rule )