From dd698775fee4c4aa6afd2c04ae2f94c70d361383 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 25 Aug 2014 04:54:00 +0300 Subject: [PATCH] zip for loops --- slpkg/slack/patches.py | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index 7f5c1999..ef353776 100755 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -41,9 +41,9 @@ def patches(): Install new patches from official Slackware mirrors ''' try: + comp_sum, uncomp_sum = [], [] + dwn_patches, comp_size, uncomp_size = [], [], [] upgrade_all, package_name, package_location = [], [], [] - comp_list, uncomp_list, comp_sum, uncomp_sum = [], [], [], [] - dwn_list, dwn_patches, comp_size, uncomp_size = [], [], [], [] pch_path = slpkg_tmp + "patches/" slack_arch = "" if not os.path.exists(pch_path): @@ -69,15 +69,12 @@ def patches(): comp_size.append(line[28:-2].strip()) if line.startswith("PACKAGE SIZE (uncompressed): "): uncomp_size.append(line[30:-2].strip()) - for loc, name in zip(package_location, package_name): - dwn_list.append("{0}{1}/{2}".format(mirrors("",""), loc, name)) - for name, size in zip(package_name, comp_size): - comp_list.append("{0}{1}".format(name, size)) - for name, size in zip(package_name, uncomp_size): - uncomp_list.append("{0}{1}".format(name, size)) - for pkg in package_name: - if not os.path.isfile(pkg_path + pkg[:-4]): - upgrade_all.append(pkg) + for loc, name, comp, uncomp in zip(package_location, package_name, comp_size, uncomp_size): + if not os.path.isfile(pkg_path + name[:-4]): + dwn_patches.append("{0}{1}/{2}".format(mirrors("",""), loc, name)) + comp_sum.append(comp) + uncomp_sum.append(uncomp) + upgrade_all.append(name) sys.stdout.write("Done\n") if upgrade_all: print("\nThese packages need upgrading:\n") @@ -85,8 +82,7 @@ def patches(): print "| Package", " "*33, "Arch", " "*3, "Build", " ", "Repos", " ", "Size" template(78) print("Upgrading:") - for upgrade, size in zip(upgrade_all, comp_list): - Kb = size.replace(upgrade, "") + for upgrade, size in zip(upgrade_all, comp_sum): if "-noarch-" in upgrade: arch = "noarch" elif "-x86_64-" in upgrade: @@ -109,16 +105,8 @@ def patches(): sp+arch+sp, ""), " "*(40-len(upgrade[:-( 5+len(slack))].replace(sp+arch+sp, ""))), arch, " "*( 7-len(arch)), upgrade[-15:-14].replace(sp+arch+sp, ""), " "*( - 6-len(upgrade[-15:-14].replace(sp+arch+sp, ""))), "Slack", " ", Kb, " "*( - 3-len(Kb)), "K" - for dwn in dwn_list: - if "/" + upgrade in dwn: - dwn_patches.append(dwn) - for install, comp, uncomp in zip(upgrade_all, comp_list, uncomp_list): - if install == comp[:-(len(comp)-len(install))]: - comp_sum.append(comp.replace(install, "")) - if install == uncomp[:-(len(uncomp)-len(install))]: - uncomp_sum.append(uncomp.replace(install, "")) + 6-len(upgrade[-15:-14].replace(sp+arch+sp, ""))), "Slack", " ", size, " "*( + 3-len(size)), "K" comp_unit, uncomp_unit = "Mb", "Mb" compressed = round((sum(map(float, comp_sum)) * 0.0001220703125), 2) uncompressed = round((sum(map(float, uncomp_sum)) * 0.0001220703125), 2)