]> git.seodisparate.com - AnotherAURHelper/commitdiff
Refactor log_print, remove unnecessary "global"
authorStephen Seo <seo.disparate@gmail.com>
Mon, 5 Sep 2022 12:54:40 +0000 (21:54 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 5 Sep 2022 12:55:29 +0000 (21:55 +0900)
Untested.

update.py

index 37a0bb52577991efbaeb32443540f4f4c372d841..935d7ff6e3770f6e1c5ed12c4124d9f6fe9fe3f9 100755 (executable)
--- 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):