Big Update
This commit is contained in:
43
setup.py
43
setup.py
@@ -4,10 +4,50 @@ import shutil
|
||||
SRC_DIR = "src"
|
||||
HOME_DIR = os.path.expanduser("~")
|
||||
|
||||
CHOICES = {
|
||||
'.config/hypr/monitors.conf': ['.config/hypr/monitors-1.conf', '.config/hypr/monitors-2.conf']
|
||||
}
|
||||
|
||||
|
||||
def ask_override(path):
|
||||
resp = input(f"'{path}' already exists. Override? (Y/N): ").strip().lower()
|
||||
return resp == 'y'
|
||||
|
||||
|
||||
def choice_files(src_root, dst_root, choices_map, override_all=False):
|
||||
for final_name, options in choices_map.items():
|
||||
existing_options = [f for f in options if os.path.exists(os.path.join(src_root, f))]
|
||||
if not existing_options:
|
||||
print(f"No source file found among options for {final_name}. Skipping.")
|
||||
continue
|
||||
|
||||
if len(existing_options) == 1:
|
||||
chosen = existing_options[0]
|
||||
else:
|
||||
print(f"Choose which file to copy as '{final_name}':")
|
||||
for idx, opt in enumerate(existing_options, 1):
|
||||
print(f"{idx}: {opt}")
|
||||
while True:
|
||||
try:
|
||||
choice_idx = int(input(f"Enter number (1-{len(existing_options)}): "))
|
||||
if 1 <= choice_idx <= len(existing_options):
|
||||
chosen = existing_options[choice_idx - 1]
|
||||
break
|
||||
except ValueError:
|
||||
pass
|
||||
print("Invalid choice, try again.")
|
||||
|
||||
src_file = os.path.join(src_root, chosen)
|
||||
dst_file = os.path.join(dst_root, final_name)
|
||||
|
||||
if os.path.exists(dst_file):
|
||||
if not override_all and not ask_override(dst_file):
|
||||
print(f"Skipped overriding {dst_file}")
|
||||
continue
|
||||
|
||||
shutil.copy2(src_file, dst_file)
|
||||
print(f"Copied {chosen} -> {final_name}")
|
||||
|
||||
def copy_with_structure(src_root, dst_root, override_all=False):
|
||||
for root, dirs, files in os.walk(src_root):
|
||||
rel_path = os.path.relpath(root, src_root)
|
||||
@@ -28,6 +68,9 @@ def copy_with_structure(src_root, dst_root, override_all=False):
|
||||
|
||||
def main():
|
||||
override_all = input('Override all existing files? (Y/N): ').strip().lower() == 'y'
|
||||
|
||||
choice_files(SRC_DIR, HOME_DIR, CHOICES, override_all)
|
||||
|
||||
copy_with_structure(SRC_DIR, HOME_DIR, override_all)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user