From 34b0d3774874eea288b3d60f8471767d36b07ae3 Mon Sep 17 00:00:00 2001 From: lededev Date: Sat, 10 Jul 2021 14:51:25 +0800 Subject: [PATCH] simplified using assignment expressions, new feature in python 3.8 --- core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core.py b/core.py index 1b517f2..7540ff0 100755 --- a/core.py +++ b/core.py @@ -599,11 +599,11 @@ def add_to_pic(pic_path, img_pic, size, count, mode): print('[-]Error: watermark image param mode invalid!') return # 先找pyinstaller打包的图片 - if hasattr(sys, '_MEIPASS') and os.path.isfile(os.path.join(getattr(sys, '_MEIPASS'), pngpath)): - mark_pic_path = os.path.join(getattr(sys, '_MEIPASS'), pngpath) + if hasattr(sys, '_MEIPASS') and os.path.isfile(_p := os.path.join(getattr(sys, '_MEIPASS'), pngpath)): + mark_pic_path = _p # 再找py脚本所在路径的图片 - elif os.path.isfile(os.path.join(os.path.dirname(os.path.realpath(__file__)), pngpath)): - mark_pic_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), pngpath) + elif os.path.isfile(_p := os.path.join(os.path.dirname(os.path.realpath(__file__)), pngpath)): + mark_pic_path = _p # 如果没有本地图片才通过网络下载 else: mark_pic_path = BytesIO(