source: fedd/fedid.py @ 8483f24

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since 8483f24 was db64553, checked in by Ted Faber <faber@…>, 15 years ago

Add an option to prepend filesnames to output.

  • Property mode set to 100755
File size: 805 bytes
Line 
1#!/usr/local/bin/python
2
3from federation import fedid
4from optparse import OptionParser
5
6
7class fedid_opts(OptionParser):
8    """Encapsulate option processing in this class, rather than in main"""
9    def __init__(self):
10        OptionParser.__init__(self, usage="%prog [opts] (--help for details)",
11                version="1.0")
12
13        self.add_option("-a", "--attribute", action="append", dest="attrs", 
14                help="Append attribute to each fedid")
15        self.add_option('--label', action='store_true', dest='label', 
16                help='Include the filename before each fedid')
17
18parser = fedid_opts()
19opts, args = parser.parse_args()
20
21for arg in args:
22    fid = fedid(file=arg)
23
24    if opts.label: l = "%s: " % arg
25    else: l = ""
26
27    if opts.attrs: print "%sfedid:%s %s" % (l, fid, ','.join(opts.attrs))
28    else: print "%sfedid:%s" % (l, fid)
29
Note: See TracBrowser for help on using the repository browser.