From 56e6ec3deb64549d4d1f739edebe96ed852c15c9 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 5 Sep 2022 21:54:40 +0900 Subject: [PATCH] Refactor log_print, remove unnecessary "global" Untested. --- update.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/update.py b/update.py index 37a0bb5..935d7ff 100755 --- a/update.py +++ b/update.py @@ -21,15 +21,17 @@ from pathlib import Path SUDO_PROC = False AUR_GIT_REPO_PATH = "https://aur.archlinux.org" AUR_GIT_REPO_PATH_TEMPLATE = AUR_GIT_REPO_PATH + "/{}.git" -global GLOBAL_LOG_FILE GLOBAL_LOG_FILE = "log.txt" DEFAULT_EDITOR = "/usr/bin/nano" -def log_print(string): - print(string) +def log_print(*args, **kwargs): + if "file" in kwargs: + kwargs["file"] = sys.stdout + print(*args, **kwargs) with open(GLOBAL_LOG_FILE, "a", encoding="utf-8") as lf: - print(string, file=lf) + kwargs["file"] = lf + print(*args, **kwargs) def ensure_pkg_dir_exists(pkg, pkg_state, other_state):