Commit f834ecbb authored by Fred Drake's avatar Fred Drake

Minor refactoring to avoid code duplication.

parent 19697bc3
...@@ -59,6 +59,13 @@ def get_size(prefix, ext): ...@@ -59,6 +59,13 @@ def get_size(prefix, ext):
fn = "%s-%s%s" % (prefix, release, ext) fn = "%s-%s%s" % (prefix, release, ext)
return int(round(os.path.getsize(fn) / 1024.0)) return int(round(os.path.getsize(fn) / 1024.0))
def get_file_cell(prefix, ext, have):
if have:
kb = get_size(prefix, ext)
return FILE_TEMPLATE % (release, prefix, release, ext, kb)
else:
return NO_FILE_TEMPLATE
for name, prefix in PKG_TYPES: for name, prefix in PKG_TYPES:
zip_fn = "%s-%s.zip" % (prefix, release) zip_fn = "%s-%s.zip" % (prefix, release)
tgz_fn = "%s-%s.tgz" % (prefix, release) tgz_fn = "%s-%s.tgz" % (prefix, release)
...@@ -71,23 +78,9 @@ for name, prefix in PKG_TYPES: ...@@ -71,23 +78,9 @@ for name, prefix in PKG_TYPES:
if have_zip or have_tgz or have_bz2: if have_zip or have_tgz or have_bz2:
print " <tr><td>%s</td>" % name print " <tr><td>%s</td>" % name
if have_zip: print get_file_cell(prefix, ".zip", have_zip)
kb = get_size(prefix, ".zip") print get_file_cell(prefix, ".tgz", have_tgz)
print FILE_TEMPLATE % (release, prefix, release, ".zip", kb) print get_file_cell(prefix, ".tar.bz2", have_bz2)
else:
print NO_FILE_TEMPLATE
if have_tgz:
kb = get_size(prefix, ".tgz")
print FILE_TEMPLATE % (release, prefix, release, ".tgz", kb)
else:
print NO_FILE_TEMPLATE
if have_bz2:
kb = get_size(prefix, ".tar.bz2")
print FILE_TEMPLATE % (release, prefix, release, ".tar.bz2", kb)
else:
print NO_FILE_TEMPLATE
print " </tr>" print " </tr>"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment