def parse_toplevel_config(self, config):
if not Formatter.initialized:<EOL><INDENT>html_theme = config.get('<STR_LIT>', '<STR_LIT:default>')<EOL>if html_theme != '<STR_LIT:default>':<EOL><INDENT>uri = urllib.parse.urlparse(html_theme)<EOL>if not uri.scheme:<EOL><INDENT>html_theme = config.get_path('<STR_LIT>')<EOL>debug("<STR_LIT>" % html_theme)<EOL><DEDENT>elif uri.scheme.startswith('<STR_LIT:http>'):<EOL><INDENT>html_theme = self.__download_theme(uri)<EOL><DEDENT><DEDENT>if html_theme == '<STR_LIT:default>':<EOL><INDENT>default_theme = os.path.join(HERE, os.pardir,<EOL>'<STR_LIT>', '<STR_LIT>')<EOL>html_theme = os.path.abspath(default_theme)<EOL>debug("<STR_LIT>")<EOL><DEDENT>theme_meta_path = os.path.join(html_theme, '<STR_LIT>')<EOL>if os.path.exists(theme_meta_path):<EOL><INDENT>with open(theme_meta_path, '<STR_LIT:r>') as _:<EOL><INDENT>Formatter.theme_meta = json.loads(_.read())<EOL><DEDENT><DEDENT>searchpath = []<EOL>self.__load_theme_templates(searchpath, HERE)<EOL>Formatter.theme_path = html_theme<EOL>if html_theme:<EOL><INDENT>self.__load_theme_templates(searchpath, html_theme)<EOL><DEDENT>Formatter.extra_theme_path = config.get_path('<STR_LIT>')<EOL>if Formatter.extra_theme_path:<EOL><INDENT>self.__load_theme_templates(searchpath,<EOL>Formatter.extra_theme_path)<EOL><DEDENT>Formatter.engine = Engine(<EOL>loader=FileLoader(searchpath, encoding='<STR_LIT>'),<EOL>extensions=[CoreExtension(), CodeExtension()])<EOL>Formatter.engine.global_vars.update({'<STR_LIT:e>': html.escape})<EOL>Formatter.initialized = True<EOL><DEDENT>
Parse @config to setup @self state.