From 4c0cc9996653960ff54ed709680ac9a347650c98 Mon Sep 17 00:00:00 2001 From: Robert Buchholz Date: Wed, 20 Aug 2008 21:13:59 +0200 Subject: Allow multiple files to be specified on the command line and remove '-f' switch for them. --- distfiles-indexer.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/distfiles-indexer.py b/distfiles-indexer.py index 49590f2..b6fb7aa 100755 --- a/distfiles-indexer.py +++ b/distfiles-indexer.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.4 +#!/usr/bin/env python import tarfile import zipfile @@ -7,7 +7,6 @@ import sys import datetime try: - # FIXME: this does not work import hashlib md5_cons = hashlib.md5 sha1_cons = hashlib.sha1 @@ -128,37 +127,35 @@ class ArchiveInfo: def main(): import getopt try: - optlist, list = getopt.getopt(sys.argv[1:], - 'f:P:hu:') + optlist, files = getopt.getopt(sys.argv[1:], + 'P:hu:') except getopt.GetoptError: usage(sys.argv[0]) sys.exit(2) - infilename = None outdir = "." for opt, arg in optlist: if opt == '-h': usage(sys.argv[0]) sys.exit(0) - if opt == '-f': - infilename = arg if opt == '-P': outdir = arg - if not infilename: + if len(files) == 0: print "Please specify a filename." else: - try: - a = ArchiveInfo(infilename) - filename = a.write_info(outdir) - except: - print infilename, " could not be opened" + for infilename in files: + try: + a = ArchiveInfo(infilename) + filename = a.write_info(outdir) + except Error, e: + print infilename, " could not be opened: %s" % str(e) def usage(programname): """ Print usage information """ - print "Usage: %s [-h] [-P ] [-f ]" % (programname) + print "Usage: %s [-h] [-P ] [ ..]" % (programname) print ''' -This script opens the file specified by -f, and writes the index to the directory specified by -P. +This script opens the file(s) specified, and writes the index to the directory specified by -P. Parameters: -h Display this help -- cgit v1.2.3-65-gdbad