#!/usr/local/bin/python # $Id: bldpdb1.py,v 1.100 2012/06/09 03:39:17 tundra Exp $ # This version opens each ZIP file individually to extract the comment # and places the result in a tmpfile which is used for later formatted output. import os import string import tempfile root = "/usr/home/pdbase/pub" # Top of the Zip archive column = 55 # Column to place Zip Comment padchar = ' ' # Padding character tmpfile = tempfile.mktemp() def BuildList(args, dir, files): for x in files: if string.lower(x[-4:]) == ".zip": cmd = "/usr/local/bin/unzip -z " filarg = "\""+dir + "/" + x + "\"" redir = ">>" + tmpfile ReadZip = cmd + filarg + redir os.system(ReadZip) os.chdir(root) os.path.walk("./", BuildList, None) f = open(tmpfile) raw = f.readlines() f.close() os.unlink(tmpfile) x = 0 y = len(raw) while (x < y): name = raw[x][9:-1] comment = raw[x+1][:-1] pad = column - len(name) print name + pad * padchar + comment x += 2