xattr-helper.py: portage.util._argparse
authorZac Medico <zmedico@gentoo.org>
Fri, 2 Aug 2013 18:05:51 +0000 (11:05 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 2 Aug 2013 18:05:51 +0000 (11:05 -0700)
bin/xattr-helper.py

index e63f2cbbd442a64c5211e786d315ee61c49eae59..a85309f4d1c297c2285ec60124811b730d86591a 100755 (executable)
@@ -1,13 +1,14 @@
 #!/usr/bin/python
-# Copyright 2012 Gentoo Foundation
+# Copyright 2012-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import array
-import optparse
 import os
 import re
 import sys
 
+from portage.util._argparse import ArgumentParser
+
 if hasattr(os, "getxattr"):
 
        class xattr(object):
@@ -128,21 +129,20 @@ def main(argv):
        usage = "usage: %s [--dump | --restore]\n" % \
                os.path.basename(argv[0])
 
-       parser = optparse.OptionParser(description=description, usage=usage)
+       parser = ArgumentParser(description=description, usage=usage)
 
-       actions = optparse.OptionGroup(parser, 'Actions')
-       actions.add_option("--dump",
+       actions = parser.add_argument_group('Actions')
+       actions.add_argument("--dump",
                action="store_true",
                help="Dump the values of all extended "
                        "attributes associated with null-separated"
                        " paths read from stdin.")
-       actions.add_option("--restore",
+       actions.add_argument("--restore",
                action="store_true",
                help="Restore extended attributes using"
                        " a dump read from stdin.")
-       parser.add_option_group(actions)
 
-       options, args = parser.parse_args(argv[1:])
+       options, args = parser.parse_known_args(argv[1:])
 
        if len(args) != 0:
                parser.error("expected zero arguments, "