* [gentoo-portage-dev] [PATCH 2/2] _argparse: punt the module
@ 2015-10-30 3:57 99% ` Mike Frysinger
0 siblings, 0 replies; 1+ results
From: Mike Frysinger @ 2015-10-30 3:57 UTC (permalink / raw
To: gentoo-portage-dev
Since we don't support python 2.6 anymore, there's no need to wrap
argparse, so switch all the users to the standard library for it.
---
bin/binhost-snapshot | 4 ++--
bin/ebuild | 4 ++--
bin/egencache | 4 ++--
bin/fixpackages | 4 ++--
bin/glsa-check | 4 ++--
bin/install.py | 4 ++--
bin/portageq | 6 +++---
bin/quickpkg | 4 ++--
bin/xattr-helper.py | 4 ++--
bin/xpak-helper.py | 4 ++--
pym/_emerge/main.py | 4 ++--
pym/portage/_emirrordist/main.py | 4 ++--
pym/portage/emaint/main.py | 6 ++----
pym/portage/sync/controller.py | 1 -
pym/portage/tests/__init__.py | 4 ++--
pym/portage/util/_argparse.py | 42 ----------------------------------------
pym/repoman/argparser.py | 4 ++--
17 files changed, 31 insertions(+), 76 deletions(-)
delete mode 100644 pym/portage/util/_argparse.py
diff --git a/bin/binhost-snapshot b/bin/binhost-snapshot
index 3a34643..4130e75 100755
--- a/bin/binhost-snapshot
+++ b/bin/binhost-snapshot
@@ -2,6 +2,7 @@
# Copyright 2010-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import argparse
import io
import os
import sys
@@ -17,7 +18,6 @@ if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), ".porta
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
portage._internal_caller = True
-from portage.util._argparse import ArgumentParser
def parse_args(argv):
prog_name = os.path.basename(argv[0])
@@ -45,7 +45,7 @@ def parse_args(argv):
"write Packages index with\n" + \
" snapshot_uri"
- parser = ArgumentParser(usage=usage)
+ parser = argparse.ArgumentParser(usage=usage)
parser.add_argument('--hardlinks',
help='create hardlinks (y or n, default is y)',
choices=('y', 'n'),
diff --git a/bin/ebuild b/bin/ebuild
index ad52ed5..59fced0 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -4,6 +4,7 @@
from __future__ import print_function
+import argparse
import platform
import signal
import sys
@@ -48,13 +49,12 @@ from portage import _shell_quote
from portage import _unicode_decode
from portage import _unicode_encode
from portage.const import VDB_PATH
-from portage.util._argparse import ArgumentParser
from _emerge.Package import Package
from _emerge.RootConfig import RootConfig
description = "See the ebuild(1) man page for more info"
usage = "Usage: ebuild <ebuild file> <command> [command] ..."
-parser = ArgumentParser(description=description, usage=usage)
+parser = argparse.ArgumentParser(description=description, usage=usage)
force_help = "When used together with the digest or manifest " + \
"command, this option forces regeneration of digests for all " + \
diff --git a/bin/egencache b/bin/egencache
index 67fca73..6407a44 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -5,6 +5,7 @@
# unicode_literals for compat with TextIOWrapper in Python 2
from __future__ import print_function, unicode_literals
+import argparse
import platform
import signal
import stat
@@ -54,7 +55,6 @@ from portage.const import TIMESTAMP_FORMAT
from portage.manifest import guessManifestFileType
from portage.package.ebuild._parallel_manifest.ManifestScheduler import ManifestScheduler
from portage.util import cmp_sort_key, writemsg_level
-from portage.util._argparse import ArgumentParser
from portage.util._async.run_main_scheduler import run_main_scheduler
from portage.util._eventloop.global_event_loop import global_event_loop
from portage import cpv_getkey
@@ -81,7 +81,7 @@ if sys.hexversion >= 0x3000000:
def parse_args(args):
usage = "egencache [options] <action> ... [atom] ..."
- parser = ArgumentParser(usage=usage)
+ parser = argparse.ArgumentParser(usage=usage)
actions = parser.add_argument_group('Actions')
actions.add_argument("--update",
diff --git a/bin/fixpackages b/bin/fixpackages
index 8a0c444..70ca9fc 100755
--- a/bin/fixpackages
+++ b/bin/fixpackages
@@ -4,6 +4,7 @@
from __future__ import print_function
+import argparse
import os
import sys
@@ -14,7 +15,6 @@ import portage
portage._internal_caller = True
from portage import os
from portage.output import EOutput
-from portage.util._argparse import ArgumentParser
from textwrap import wrap
from portage._global_updates import _global_updates
mysettings = portage.settings
@@ -25,7 +25,7 @@ description = """The fixpackages program performs package move updates on
configuration files, installed packages, and binary packages."""
description = " ".join(description.split())
-parser = ArgumentParser(description=description)
+parser = argparse.ArgumentParser(description=description)
parser.parse_args()
if mysettings['ROOT'] != "/":
diff --git a/bin/glsa-check b/bin/glsa-check
index 94dea73..84481d8 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -4,6 +4,7 @@
from __future__ import print_function
+import argparse
import sys
import codecs
@@ -14,7 +15,6 @@ import portage
portage._internal_caller = True
from portage import os
from portage.output import green, red, nocolor, white
-from portage.util._argparse import ArgumentParser
__program__ = "glsa-check"
__author__ = "Marius Mauch <genone@gentoo.org>"
@@ -24,7 +24,7 @@ __version__ = "1.0"
epilog = "glsa-list can contain an arbitrary number of GLSA ids," \
" filenames containing GLSAs or the special identifiers" \
" 'all', 'new' and 'affected'"
-parser = ArgumentParser(usage=__program__ + " <option> [glsa-list]",
+parser = argparse.ArgumentParser(usage=__program__ + " <option> [glsa-list]",
epilog=epilog)
modes = parser.add_argument_group("Modes")
diff --git a/bin/install.py b/bin/install.py
index 5bbe97b..d3789ed 100755
--- a/bin/install.py
+++ b/bin/install.py
@@ -2,6 +2,7 @@
# Copyright 2013-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import argparse
import os
import stat
import sys
@@ -9,7 +10,6 @@ import subprocess
import traceback
import portage
-from portage.util._argparse import ArgumentParser
from portage.util.movefile import _copyxattr
from portage.exception import OperationNotSupported
@@ -24,7 +24,7 @@ def parse_args(args):
Returns:
tuple of the Namespace of parsed options, and a list of order parameters
"""
- parser = ArgumentParser(add_help=False)
+ parser = argparse.ArgumentParser(add_help=False)
parser.add_argument(
"-b",
diff --git a/bin/portageq b/bin/portageq
index 649ee04..548d090 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -4,6 +4,7 @@
from __future__ import print_function, unicode_literals
+import argparse
import signal
import sys
# This block ensures that ^C interrupts are handled quietly.
@@ -44,7 +45,6 @@ portage._internal_caller = True
from portage import os
from portage.eapi import eapi_has_repo_deps
from portage.util import writemsg, writemsg_stdout
-from portage.util._argparse import ArgumentParser
portage.proxy.lazyimport.lazyimport(globals(),
're',
'subprocess',
@@ -1310,7 +1310,7 @@ def usage(argv):
print()
print('Pkgcore pquery compatible options:')
print()
- parser = ArgumentParser(add_help=False,
+ parser = argparse.ArgumentParser(add_help=False,
usage='portageq pquery [options] [atom ...]')
add_pquery_arguments(parser)
parser.print_help()
@@ -1342,7 +1342,7 @@ def main(argv):
if nocolor in ('yes', 'true'):
portage.output.nocolor()
- parser = ArgumentParser(add_help=False)
+ parser = argparse.ArgumentParser(add_help=False)
# used by envvar
parser.add_argument("-v", dest="verbose", action="store_true")
diff --git a/bin/quickpkg b/bin/quickpkg
index 262fda4..4f26ee9 100755
--- a/bin/quickpkg
+++ b/bin/quickpkg
@@ -4,6 +4,7 @@
from __future__ import division, print_function
+import argparse
import errno
import math
import signal
@@ -26,7 +27,6 @@ xattr = _xattr.xattr
from portage.dbapi.vartree import dblink, tar_contents
from portage.checksum import perform_md5
from portage._sets import load_default_config, SETPREFIX
-from portage.util._argparse import ArgumentParser
def quickpkg_atom(options, infos, arg, eout):
settings = portage.settings
@@ -302,7 +302,7 @@ def quickpkg_main(options, args, eout):
if __name__ == "__main__":
usage = "quickpkg [options] <list of package atoms or package sets>"
- parser = ArgumentParser(usage=usage)
+ parser = argparse.ArgumentParser(usage=usage)
parser.add_argument("--umask",
default="0077",
help="umask used during package creation (default is 0077)")
diff --git a/bin/xattr-helper.py b/bin/xattr-helper.py
index 19f25f9..b5faed0 100755
--- a/bin/xattr-helper.py
+++ b/bin/xattr-helper.py
@@ -13,12 +13,12 @@ https://en.wikipedia.org/wiki/Extended_file_attributes
__doc__ = doc
+import argparse
import array
import os
import re
import sys
-from portage.util._argparse import ArgumentParser
from portage.util._xattr import xattr
@@ -140,7 +140,7 @@ def restore_xattrs(file_in):
def main(argv):
- parser = ArgumentParser(description=doc)
+ parser = argparse.ArgumentParser(description=doc)
parser.add_argument('paths', nargs='*', default=[])
actions = parser.add_argument_group('Actions')
diff --git a/bin/xpak-helper.py b/bin/xpak-helper.py
index c4391cd..8c965ec 100755
--- a/bin/xpak-helper.py
+++ b/bin/xpak-helper.py
@@ -2,11 +2,11 @@
# Copyright 2009-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import argparse
import sys
import portage
portage._internal_caller = True
from portage import os
-from portage.util._argparse import ArgumentParser
def command_recompose(args):
@@ -46,7 +46,7 @@ def main(argv):
usage = "usage: %s COMMAND [args]" % \
os.path.basename(argv[0])
- parser = ArgumentParser(description=description, usage=usage)
+ parser = argparse.ArgumentParser(description=description, usage=usage)
options, args = parser.parse_known_args(argv[1:])
if not args:
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index b69aa24..e75bb0a 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -3,6 +3,7 @@
from __future__ import print_function
+import argparse
import locale
import platform
import sys
@@ -19,7 +20,6 @@ portage.proxy.lazyimport.lazyimport(globals(),
'_emerge.is_valid_package_atom:insert_category_into_atom'
)
from portage import os
-from portage.util._argparse import ArgumentParser
from portage.sync import _SUBMODULE_PATH_MAP
if sys.hexversion >= 0x3000000:
@@ -705,7 +705,7 @@ def parse_opts(tmpcmdline, silent=False):
},
}
- parser = ArgumentParser(add_help=False)
+ parser = argparse.ArgumentParser(add_help=False)
for action_opt in actions:
parser.add_argument("--" + action_opt, action="store_true",
diff --git a/pym/portage/_emirrordist/main.py b/pym/portage/_emirrordist/main.py
index ce92c2a..7378ac7 100644
--- a/pym/portage/_emirrordist/main.py
+++ b/pym/portage/_emirrordist/main.py
@@ -1,13 +1,13 @@
# Copyright 2013-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import argparse
import logging
import sys
import portage
from portage import os
from portage.util import normalize_path, writemsg_level, _recursive_file_list
-from portage.util._argparse import ArgumentParser
from portage.util._async.run_main_scheduler import run_main_scheduler
from portage.util._async.SchedulerInterface import SchedulerInterface
from portage.util._eventloop.global_event_loop import global_event_loop
@@ -202,7 +202,7 @@ def parse_args(args):
description = "emirrordist - a fetch tool for mirroring " \
"of package distfiles"
usage = "emirrordist [options] <action>"
- parser = ArgumentParser(description=description, usage=usage)
+ parser = argparse.ArgumentParser(description=description, usage=usage)
actions = parser.add_argument_group('Actions')
actions.add_argument("--version",
diff --git a/pym/portage/emaint/main.py b/pym/portage/emaint/main.py
index e71efe8..65e3545 100644
--- a/pym/portage/emaint/main.py
+++ b/pym/portage/emaint/main.py
@@ -3,7 +3,7 @@
from __future__ import print_function
-
+import argparse
import sys
import textwrap
@@ -12,7 +12,6 @@ from portage import os
from portage.module import Modules
from portage.progress import ProgressBar
from portage.emaint.defaults import DEFAULT_OPTIONS
-from portage.util._argparse import ArgumentParser
class OptionItem(object):
"""class to hold module ArgumentParser options data
@@ -169,8 +168,7 @@ def emaint_main(myargv):
module_names = module_controller.module_names[:]
module_names.insert(0, "all")
-
- parser = ArgumentParser(usage=usage(module_controller))
+ parser = argparse.ArgumentParser(usage=usage(module_controller))
# add default options
parser_options = []
for opt in DEFAULT_OPTIONS:
diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py
index 159b9c0..e8132c2 100644
--- a/pym/portage/sync/controller.py
+++ b/pym/portage/sync/controller.py
@@ -13,7 +13,6 @@ import portage
from portage import os
from portage.progress import ProgressBar
#from portage.emaint.defaults import DEFAULT_OPTIONS
-#from portage.util._argparse import ArgumentParser
from portage.util import writemsg, writemsg_level
from portage.output import create_color_func
good = create_color_func("GOOD")
diff --git a/pym/portage/tests/__init__.py b/pym/portage/tests/__init__.py
index 708dd59..bf681c4 100644
--- a/pym/portage/tests/__init__.py
+++ b/pym/portage/tests/__init__.py
@@ -4,6 +4,7 @@
from __future__ import print_function
+import argparse
import sys
import time
import unittest
@@ -27,7 +28,6 @@ from portage import _encodings
from portage import _unicode_decode
from portage.const import (EPREFIX, GLOBAL_CONFIG_PATH, PORTAGE_BASE_PATH,
PORTAGE_BIN_PATH)
-from portage.util._argparse import ArgumentParser
if portage._not_installed:
@@ -48,7 +48,7 @@ def main():
basedir = os.path.dirname(os.path.realpath(__file__))
usage = "usage: %s [options] [tests to run]" % os.path.basename(sys.argv[0])
- parser = ArgumentParser(usage=usage)
+ parser = argparse.ArgumentParser(usage=usage)
parser.add_argument("-l", "--list", help="list all tests",
action="store_true", dest="list_tests")
options, args = parser.parse_known_args(args=sys.argv)
diff --git a/pym/portage/util/_argparse.py b/pym/portage/util/_argparse.py
deleted file mode 100644
index 6ca7852..0000000
--- a/pym/portage/util/_argparse.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-__all__ = ['ArgumentParser']
-
-try:
- from argparse import ArgumentParser
-except ImportError:
- # Compatibility with Python 2.6 and 3.1
- from optparse import OptionGroup, OptionParser
-
- from portage.localization import _
-
- class ArgumentParser(object):
- def __init__(self, **kwargs):
- add_help = kwargs.pop("add_help", None)
- if add_help is not None:
- kwargs["add_help_option"] = add_help
- parser = OptionParser(**kwargs)
- self._parser = parser
- self.add_argument = parser.add_option
- self.print_help = parser.print_help
- self.error = parser.error
-
- def add_argument_group(self, title=None, **kwargs):
- optiongroup = OptionGroup(self._parser, title, **kwargs)
- self._parser.add_option_group(optiongroup)
- return _ArgumentGroup(optiongroup)
-
- def parse_known_args(self, args=None, namespace=None):
- return self._parser.parse_args(args, namespace)
-
- def parse_args(self, args=None, namespace=None):
- args, argv = self.parse_known_args(args, namespace)
- if argv:
- msg = _('unrecognized arguments: %s')
- self.error(msg % ' '.join(argv))
- return args
-
- class _ArgumentGroup(object):
- def __init__(self, optiongroup):
- self.add_argument = optiongroup.add_option
diff --git a/pym/repoman/argparser.py b/pym/repoman/argparser.py
index 0f34ed0..2d56a87 100644
--- a/pym/repoman/argparser.py
+++ b/pym/repoman/argparser.py
@@ -4,6 +4,7 @@
"""This module contains functions used in Repoman to parse CLI arguments."""
+import argparse
import logging
import sys
@@ -12,7 +13,6 @@ from repoman._portage import portage
from portage import _unicode_decode
from portage import util
-from portage.util._argparse import ArgumentParser
def parse_args(argv, qahelp, repoman_default_opts):
@@ -47,7 +47,7 @@ def parse_args(argv, qahelp, repoman_default_opts):
output_keys = sorted(output_choices)
- parser = ArgumentParser(
+ parser = argparse.ArgumentParser(
usage="repoman [options] [mode]",
description="Modes: %s" % " | ".join(mode_keys),
epilog="For more help consult the man page.")
--
2.5.2
^ permalink raw reply related [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-10-30 3:57 [gentoo-portage-dev] [PATCH 1/2] chpathtool: drop optparse compat logic Mike Frysinger
2015-10-30 3:57 99% ` [gentoo-portage-dev] [PATCH 2/2] _argparse: punt the module Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox