#!/usr/bin/env python from deter import fedid from optparse import OptionParser class fedid_opts(OptionParser): """Encapsulate option processing in this class, rather than in main""" def __init__(self): OptionParser.__init__(self, usage="%prog [opts] (--help for details)", version="1.0") self.add_option("-a", "--attribute", action="append", dest="attrs", help="Append attribute to each fedid") self.add_option('--label', action='store_true', dest='label', help='Include the filename before each fedid') parser = fedid_opts() opts, args = parser.parse_args() for arg in args: fid = fedid(file=arg) if opts.label: l = "%s: " % arg else: l = "" if opts.attrs: print "%sfedid:%s %s" % (l, fid, ','.join(opts.attrs)) else: print "%sfedid:%s" % (l, fid)