#!/usr/local/bin/python
# $Id: bldpdb2.py,v 1.100 2012/06/09 03:39:17 tundra Exp $
# This version opens up all the ZIP files in a given directory at once
# and extracts their comments into a tmpfile 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):
cmd = "/usr/local/bin/unzip -z "
filarg = "\""+dir + "/*\""
redir = " 2>/dev/null >>" + 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):
if (raw[x][:7] == "Archive") and (string.lower(raw[x][-4:-1]) == "zip"):
name = raw[x][9:-1]
comment = raw[x+1][:-1]
pad = column - len(name)
print name + pad * padchar + comment
x += 2
else:
x += 1