diff --git a/core/services/template/services.py b/core/services/template/services.py index 546ad7bb..07ae1e1e 100644 --- a/core/services/template/services.py +++ b/core/services/template/services.py @@ -182,7 +182,7 @@ class TemplatePreviewer(BaseService, load=application_config.webserver.enable an @self.web_app.get("/preview/{path:path}") async def preview_template(path: str, key: Optional[str] = None): # pylint: disable=W0612 # 如果是 /preview/ 开头的静态文件,直接返回内容。比如使用相对链接 ../ 引入的静态资源 - if not (path.endswith(".html") ^ path.endswith(".jinja2")): + if not path.endswith((".html", ".jinja2")): full_path = self.template_service.template_dir / path if not full_path.is_file(): raise HTTPException(status_code=404, detail=f"Template '{path}' not found") diff --git a/metadata/scripts/metadatas.py b/metadata/scripts/metadatas.py index 8caa615b..72ff712c 100644 --- a/metadata/scripts/metadatas.py +++ b/metadata/scripts/metadatas.py @@ -89,7 +89,9 @@ async def update_metadata_from_github(overwrite: bool = True): text_map_json_data = {} async with client.stream("GET", text_map_url) as response: async for line in response.aiter_lines(): - if (string_id := (splits := line.split(":"))[0].strip(' "')) in string_ids: + splits = line.split(":") + string_id = splits[0].strip(' "') + if string_id in string_ids: text_map_json_data[string_id] = splits[1].strip('\n ,"') string_ids.remove(string_id) if not string_ids: