axis_examplecompt_changesinfo-ops
Last change
on this file since 771a277 was
2e46f35,
checked in by mikeryan <mikeryan@…>, 14 years ago
|
switch to /usr/bin/env python to run python
|
-
Property mode set to
100755
|
File size:
803 bytes
|
Rev | Line | |
---|
[2e46f35] | 1 | #!/usr/bin/env python |
---|
[f816079] | 2 | |
---|
[5d3f239] | 3 | from federation import fedid |
---|
[f816079] | 4 | from optparse import OptionParser |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | class 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") |
---|
[db64553] | 15 | self.add_option('--label', action='store_true', dest='label', |
---|
| 16 | help='Include the filename before each fedid') |
---|
[f816079] | 17 | |
---|
| 18 | parser = fedid_opts() |
---|
| 19 | opts, args = parser.parse_args() |
---|
| 20 | |
---|
| 21 | for arg in args: |
---|
| 22 | fid = fedid(file=arg) |
---|
[db64553] | 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) |
---|
[f816079] | 29 | |
---|
Note: See
TracBrowser
for help on using the repository browser.