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/install.py | 47 +++++++++++++++++++++++++++++++++++------------ src/backend/update.py | 18 ++++++++++++------ src/backend/upgrade.py | 47 +++++++++++++++++++++++++++++++++++------------ 3 files changed, 82 insertions(+), 30 deletions(-) diff --git a/src/backend/install.py b/src/backend/install.py index aaab797..b742708 100644 --- a/src/backend/install.py +++ b/src/backend/install.py @@ -75,8 +75,12 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=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 + "]" + " ") @@ -101,10 +105,19 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=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 + "]" + " ") @@ -131,8 +144,12 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=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 + "]" + " ") @@ -195,8 +212,10 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=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=False, gfx_ui=True) os.chdir(sisyphus.getfs.p_cch_dir) p_exe = subprocess.Popen(['emerge', '--quiet', '--verbose', '--usepkg', '--usepkgonly', '--rebuilt-binaries', '--with-bdeps=y', @@ -210,8 +229,12 @@ def start(pkgname, ebuild=False, gfx_ui=False, oneshot=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 + "]" + " ") diff --git a/src/backend/update.py b/src/backend/update.py index f369c97..face3f2 100644 --- a/src/backend/update.py +++ b/src/backend/update.py @@ -50,11 +50,15 @@ def start(gfx_ui=False): sync_evrth() else: if "packages-next" in bhst_addr: - print(sisyphus.getcolor.green + "\n\nActive branch:" + " " + sisyphus.getcolor.reset + "'" + actv_brch + "'" + " " + "(stable)" + - " " + sisyphus.getcolor.green + "\nActive binhost:" + " " + sisyphus.getcolor.reset + "'" + bhst_addr + "'" + " " + "(testing)") + print(sisyphus.getcolor.green + "\n\nActive branch:" + " " + + sisyphus.getcolor.reset + "'" + actv_brch + "'" + " " + "(stable)") + print(sisyphus.getcolor.green + "\nActive binhost:" + " " + + sisyphus.getcolor.reset + "'" + bhst_addr + "'" + " " + "(testing)") else: - print(sisyphus.getcolor.green + "\n\nActive branch:" + " " + sisyphus.getcolor.reset + "'" + actv_brch + "'" + " " + "(testing)" + - " " + sisyphus.getcolor.green + "\nActive binhost:" + " " + sisyphus.getcolor.reset + "'" + bhst_addr + "'" + " " + "(stable)") + print(sisyphus.getcolor.green + "\n\nActive branch:" + " " + + sisyphus.getcolor.reset + "'" + actv_brch + "'" + " " + "(testing)") + print(sisyphus.getcolor.green + "\nActive binhost:" + " " + + sisyphus.getcolor.reset + "'" + bhst_addr + "'" + " " + "(stable)") if gfx_ui: print("\n\nInvalid configuration!") @@ -65,6 +69,8 @@ def start(gfx_ui=False): sys.exit(app.exec_()) # kill GUI window else: - print(sisyphus.getcolor.bright_red + "\n\nInvalid configuration!" + sisyphus.getcolor.reset + sisyphus.getcolor.bright_yellow + "\nUse" + - sisyphus.getcolor.reset + " " + "'" + "sisyphus branch --help" + "'" + " " + sisyphus.getcolor.bright_yellow + "for help" + sisyphus.getcolor.reset) + print(sisyphus.getcolor.bright_red + + "\n\nInvalid configuration!" + sisyphus.getcolor.reset) + print(sisyphus.getcolor.bright_yellow + "\nUse" + sisyphus.getcolor.reset + " " + "'" + + "sisyphus branch --help" + "'" + " " + sisyphus.getcolor.bright_yellow + "for help" + sisyphus.getcolor.reset) sys.exit() 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