Ensure python standard argparse module is loaded
When 'import argparse' is used in cliff.something module, cliff.argparse is loaded instead of python standard argparse. This causes cliff.sphinxext failure with no attribute _HelpAction. This can be avoided by renaming cliff.argparse to non-overlapping module name like _argparse. cliff.argparse is for internal use, so I believe it is safe to rename the module. Closes-Bug: #1692018 Change-Id: Ic34f61581316c662dd2d672bc2c088dcef2100a9
This commit is contained in:
@@ -22,7 +22,7 @@ import os
|
|||||||
import six
|
import six
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from cliff import argparse
|
from cliff import _argparse
|
||||||
from . import complete
|
from . import complete
|
||||||
from . import help
|
from . import help
|
||||||
from . import utils
|
from . import utils
|
||||||
@@ -143,7 +143,7 @@ class App(object):
|
|||||||
:paramtype extra_kwargs: dict
|
:paramtype extra_kwargs: dict
|
||||||
"""
|
"""
|
||||||
argparse_kwargs = argparse_kwargs or {}
|
argparse_kwargs = argparse_kwargs or {}
|
||||||
parser = argparse.ArgumentParser(
|
parser = _argparse.ArgumentParser(
|
||||||
description=description,
|
description=description,
|
||||||
add_help=False,
|
add_help=False,
|
||||||
**argparse_kwargs
|
**argparse_kwargs
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import inspect
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from cliff import argparse
|
from cliff import _argparse
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
@@ -67,7 +67,7 @@ class Command(object):
|
|||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
"""Return an :class:`argparse.ArgumentParser`.
|
"""Return an :class:`argparse.ArgumentParser`.
|
||||||
"""
|
"""
|
||||||
parser = argparse.ArgumentParser(
|
parser = _argparse.ArgumentParser(
|
||||||
description=self.get_description(),
|
description=self.get_description(),
|
||||||
epilog=self.get_epilog(),
|
epilog=self.get_epilog(),
|
||||||
prog=prog_name,
|
prog=prog_name,
|
||||||
@@ -97,7 +97,7 @@ class Command(object):
|
|||||||
return self.take_action(parsed_args) or 0
|
return self.take_action(parsed_args) or 0
|
||||||
|
|
||||||
|
|
||||||
class _SmartHelpFormatter(argparse.HelpFormatter):
|
class _SmartHelpFormatter(_argparse.HelpFormatter):
|
||||||
"""Smart help formatter to output raw help message if help contain \n.
|
"""Smart help formatter to output raw help message if help contain \n.
|
||||||
|
|
||||||
Some command help messages maybe have multiple line content, the built-in
|
Some command help messages maybe have multiple line content, the built-in
|
||||||
|
|||||||
Reference in New Issue
Block a user