mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-14 15:58:38 -05:00
remove python2 support from awxkit
This commit is contained in:
@@ -5,8 +5,6 @@ import os
|
||||
import sys
|
||||
import threading
|
||||
|
||||
import six
|
||||
|
||||
_color = threading.local()
|
||||
_color.enabled = True
|
||||
|
||||
@@ -38,29 +36,6 @@ class CustomRegistryMeta(type):
|
||||
|
||||
class HelpfulArgumentParser(ArgumentParser):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HelpfulArgumentParser, self).__init__(*args, **kwargs)
|
||||
if six.PY2:
|
||||
# backport parser aliases support to py2
|
||||
# see: https://github.com/python/cpython/commit/fd311a712d5876c3a3efff265978452eea759f85
|
||||
SubParsersAction = self._registries['action']['parsers']
|
||||
|
||||
class _SubParsersAction(SubParsersAction):
|
||||
|
||||
def add_parser(self, name, **kwargs):
|
||||
aliases = kwargs.pop('aliases', [])
|
||||
parser = super(_SubParsersAction, self).add_parser(name, **kwargs)
|
||||
if aliases:
|
||||
self._choices_actions[-1].metavar = ' '.join([
|
||||
name,
|
||||
'({})'.format(', '.join(aliases))
|
||||
])
|
||||
for alias in aliases:
|
||||
self._name_parser_map[alias] = parser
|
||||
return parser
|
||||
|
||||
self._registries['action']['parsers'] = _SubParsersAction
|
||||
|
||||
def error(self, message): # pragma: nocover
|
||||
"""Prints a usage message incorporating the message to stderr and
|
||||
exits.
|
||||
|
||||
Reference in New Issue
Block a user