From 967023aae085b303fa35a3c9572311b953ae8ae9 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sat, 13 Feb 2021 15:33:02 -0500 Subject: [PATCH] Don't overwrite existing local config file --- setup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 939a721..639de53 100644 --- a/setup.py +++ b/setup.py @@ -19,14 +19,17 @@ if os.geteuid() == 0: shutil.copyfile("./config.py", "/etc/lightcards/config.py") else: xdg = os.environ.get("XDG_CONFIG_HOME") + xdg_dest = f"{xdg}/lightcards/config.py" + home = os.path.expanduser("~") + home_dest = f"{home}/.config/lightcards/config.py" - if xdg: + if xdg and not os.path.exists(xdg_dest): mkdir(f"{xdg}/lightcards") - shutil.copyfile("./config.py", f"{xdg}/lightcards/config.py") - else: + shutil.copyfile("./config.py", xdg_dest) + elif not os.path.exists(home_dest): mkdir(f"{home}/.config/lightcards") - shutil.copyfile("./config.py", f"{home}/.config/lightcards/config.py") + shutil.copyfile("./config.py", home_dest) setup( -- 2.39.2