From bb61bf8a125d22bf28d65b5b44a72c6f409202b1 Mon Sep 17 00:00:00 2001 From: carolcoral <947752894@qq.com> Date: Wed, 6 Sep 2023 19:18:11 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=A2=9E=E5=8A=A0python=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=A4=E6=96=AD=E5=85=BC=E5=AE=B9xml=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analyze.py | 7 ++++++- main.py | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/analyze.py b/analyze.py index e978634..f739cc5 100644 --- a/analyze.py +++ b/analyze.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- import json +import sys import xml.etree.ElementTree as ET from xml.dom.minidom import Document @@ -51,5 +52,9 @@ class Make: value = doc.createTextNode(str(self.data[key])) key_node.appendChild(value) f = open(file=self.xml_path, mode="w") - doc.writexml(writer=f, addindent=" ", newl="\n", encoding="utf-8", standalone="yes") + python_version = sys.version_info.minor + if 8 == python_version: + doc.writexml(writer=f, addindent=" ", newl="\n", encoding="utf-8") + elif 8 < python_version: + doc.writexml(writer=f, addindent=" ", newl="\n", encoding="utf-8", standalone="yes") f.close() diff --git a/main.py b/main.py index 90dae17..5c30e84 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,24 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- import os -from utils.LoggerUtil import Logger -from tmdb import Tmdb +import sys + from analyze import Analyze +from tmdb import Tmdb +from utils.LoggerUtil import Logger + + +def __check_version(): + version_info = sys.version_info + if 3 > version_info.major: + log.logger.error("当前Python版本不能小于3!") + raise SystemExit(1) + else: + if 8 > version_info.minor: + log.logger.error("当前Python版本不能小于3.8!") + raise SystemExit(1) + elif 8 == version_info.minor: + log.logger.warn("推荐使用Python 3.9 及以上版本!") def __init_logger(log_file="tmdb.log", level="info", back_count=3): @@ -67,6 +82,8 @@ if __name__ == '__main__': __tmdb_token = "tmdb_token" # 初始化日志 log = __init_logger() + # 检查python版本 + __check_version() # 开始执行主程序 # 默认 language="zh-CN" (简体中文),可以通过修改 "language" 的值变更获取元数据的语言类别 __execute(dir_path=__dir_path, output=__output, tmdb_token=__tmdb_token)