summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Buchholz <rbu@goodpoint.de>2008-08-20 21:13:59 +0200
committerRobert Buchholz <rbu@goodpoint.de>2008-08-20 21:13:59 +0200
commit4c0cc9996653960ff54ed709680ac9a347650c98 (patch)
tree465c41883c3c67cebc1025a8b0f53cb5c720f396
parentEbuild indexing script. (diff)
downloaddistindex-4c0cc9996653960ff54ed709680ac9a347650c98.tar.gz
distindex-4c0cc9996653960ff54ed709680ac9a347650c98.tar.bz2
distindex-4c0cc9996653960ff54ed709680ac9a347650c98.zip
Allow multiple files to be specified on the command line
and remove '-f' switch for them.
-rwxr-xr-xdistfiles-indexer.py27
1 files 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 <dir>] [-f <file>]" % (programname)
+ print "Usage: %s [-h] [-P <dir>] <file> [<file> ..]" % (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