From 852b8d6c7dba32c9051e479ae9e0613b4126f109 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 7 Jul 2024 20:27:42 +0200 Subject: [PATCH] args: remove dead code (MR 2349) Remove a bunch of commented out code: * debug leftovers * update_work(): a function that used to replace $WORK in all kinds of arguments to pmbootstrap, with the actual work dir. This seemed like a good idea when I made this initially, but in hindsight it's clear that this made args just much more complex. I'm glad that Caleb removed this. Now $WORK only gets removed in one place, for mount points, which makes much more sense. * args.from_argparse and related comment: pmbootstrap used to make a full copy of its args, so in some cases it could go back before $WORK was replaced IIRC. This isn't great, but even worse is that this caused each stack trace to say something like infinite recursion on args. I'm also glad that Caleb got rid of this :) --- pmb/helpers/args.py | 23 ----------------------- pmb/parse/arguments.py | 4 ---- 2 files changed, 27 deletions(-) diff --git a/pmb/helpers/args.py b/pmb/helpers/args.py index 7a5ee342..67be2cdf 100644 --- a/pmb/helpers/args.py +++ b/pmb/helpers/args.py @@ -131,32 +131,9 @@ def init(args: PmbArgs) -> PmbArgs: if not key.startswith("_") and not key == "from_argparse": setattr(__args, key, value) - # print(json.dumps(__args.__dict__)) - - # sys.exit(0) - return __args -# def update_work(args: PmbArgs, work): -# """Update the work path in args.work and wherever $WORK was used.""" -# # Start with the unmodified args from argparse -# args_new = copy.deepcopy(args.from_argparse) - -# # Keep from the modified args: -# # * the unmodified args from argparse (to check if --aports was specified) -# args_new.from_argparse = args.from_argparse - -# # Generate modified args again, replacing $WORK with the new work folder -# # When args.log is different, this also opens the log in the new location -# args_new.work = work -# args_new = pmb.helpers.args.init(args_new) - -# # Overwrite old attributes of args with the new attributes -# for key in vars(args_new): -# setattr(args, key, getattr(args_new, key)) - - def please_i_really_need_args() -> PmbArgs: import traceback diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index 354857ba..21439a3e 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -1277,12 +1277,8 @@ def get_parser(): def arguments(): - # Parse and extend arguments (also backup unmodified result from argparse) args: PmbArgs = get_parser().parse_args() - # setattr(args, "from_argparse", copy.deepcopy(args)) - # setattr(args.from_argparse, "from_argparse", args.from_argparse) - if getattr(args, "fork_alpine_retain_branch", False): # fork_alpine_retain_branch largely matches the behaviour of fork_alpine, so # just set fork_alpine here to reduce repetition.