From c07b06aa7ab944b5fee70d5a37ef60a45ff1c24b Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 15 Apr 2023 15:09:48 +0100 Subject: split extra long prints into smaller ones, improve code readability --- src/backend/upgrade.py | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'src/backend/upgrade.py') diff --git a/src/backend/upgrade.py b/src/backend/upgrade.py index 8de534a..bf2c1e7 100644 --- a/src/backend/upgrade.py +++ b/src/backend/upgrade.py @@ -78,8 +78,12 @@ def start(ebuild=False, gfx_ui=False): if ebuild: # ebuild mode if len(bin_list) == 0 and len(src_list) != 0: # source mode, ignore aliens - print("\n" + sisyphus.getcolor.green + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.green + ", ".join( - src_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(src_list)) + " " + "source package(s)" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.green + + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.green + + ", ".join(src_list) + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str( + len(src_list)) + " " + "source package(s)" + sisyphus.getcolor.reset + "\n") while True: user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") @@ -104,10 +108,19 @@ def start(ebuild=False, gfx_ui=False): user_input + "'" + " " + "not understood.\n") continue elif len(bin_list) != 0 and len(src_list) != 0: # hybrid mode, ignore aliens - print("\n" + sisyphus.getcolor.green + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.magenta + ", ".join( - bin_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") - print("\n" + sisyphus.getcolor.green + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.green + ", ".join( - src_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(src_list)) + " " + "source package(s)" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.green + + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.magenta + + ", ".join(bin_list) + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str( + len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") + + print("\n" + sisyphus.getcolor.green + + "These are the source packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.green + + ", ".join(src_list) + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str( + len(src_list)) + " " + "source package(s)" + sisyphus.getcolor.reset + "\n") while True: user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") @@ -134,8 +147,12 @@ def start(ebuild=False, gfx_ui=False): user_input + "'" + " " + "not understood.\n") continue elif len(bin_list) != 0 and len(src_list) == 0: # binary mode, fallback - print("\n" + sisyphus.getcolor.green + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.magenta + ", ".join( - bin_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.green + + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.magenta + + ", ".join(bin_list) + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str( + len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") while True: user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") @@ -198,8 +215,10 @@ def start(ebuild=False, gfx_ui=False): sys.exit() elif len(bin_list) != 0 and len(src_list) == 0: # binary mode if gfx_ui: - print("\n" + "These are the binary packages that will be merged, in order:" + "\n\n" + ", ".join( - bin_list) + "\n\n" + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + "\n\n") + print( + "\n" + "These are the binary packages that will be merged, in order:" + "\n") + print("\n" + ", ".join(bin_list) + "\n\n" + "Total:" + " " + + str(len(bin_list)) + " " + "binary package(s)" + "\n\n") sisyphus.download.start(dl_world=True, gfx_ui=True) os.chdir(sisyphus.getfs.p_cch_dir) p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--update', '--deep', '--newuse', '--usepkg', '--usepkgonly', '--rebuilt-binaries', @@ -213,8 +232,12 @@ def start(ebuild=False, gfx_ui=False): p_exe.wait() sisyphus.syncdb.lcl_tbl() else: - print("\n" + sisyphus.getcolor.green + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.magenta + ", ".join( - bin_list) + sisyphus.getcolor.reset + "\n\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str(len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.green + + "These are the binary packages that would be merged, in order:" + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.magenta + + ", ".join(bin_list) + sisyphus.getcolor.reset + "\n") + print("\n" + sisyphus.getcolor.bright_white + "Total:" + " " + str( + len(bin_list)) + " " + "binary package(s)" + sisyphus.getcolor.reset + "\n") while True: user_input = input(sisyphus.getcolor.bright_white + "Would you like to proceed?" + sisyphus.getcolor.reset + " " + "[" + sisyphus.getcolor.bright_green + "Yes" + sisyphus.getcolor.reset + "/" + sisyphus.getcolor.bright_red + "No" + sisyphus.getcolor.reset + "]" + " ") -- cgit v1.2.3