zip for loops

This commit is contained in:
Dimitris Zlatanidis 2014-08-25 04:54:00 +03:00
parent 7d7e2814ca
commit dd698775fe

View file

@ -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)