remove OD if name == description is now managed with internal argparser mechanism

This commit is contained in:
2019-07-28 22:44:17 +02:00
parent 9bc52bcbbb
commit 79ddb8bc11
2 changed files with 14 additions and 19 deletions

View File

@ -128,13 +128,6 @@ class TiramisuHelpFormatter:
len(self.items) == 1 and \
self.items[0][0].__name__ == '_format_text':
return ''
# Remove OD if name == description
if self.formatter.remove_empty_description_od and \
self.items is not None and \
self.heading is not None and \
len(self.items) > 1 and \
self.items[0][0].__name__ != '_format_text':
return ''
return super().format_help()
@ -227,7 +220,6 @@ class TiramisuCmdlineParser(ArgumentParser):
root: str=None,
fullpath: bool=True,
remove_empty_od: bool=False,
remove_empty_description_od: bool=False,
formatter_class=HelpFormatter,
_forhelp: bool=False,
**kwargs):
@ -235,11 +227,9 @@ class TiramisuCmdlineParser(ArgumentParser):
self.config = config
self.root = root
self.remove_empty_od = remove_empty_od
self.remove_empty_description_od = remove_empty_description_od
if TiramisuHelpFormatter not in formatter_class.__mro__:
formatter_class = type('TiramisuHelpFormatter', (TiramisuHelpFormatter, formatter_class), {})
formatter_class.remove_empty_od = self.remove_empty_od
formatter_class.remove_empty_description_od = self.remove_empty_description_od
kwargs['formatter_class'] = formatter_class
if self.root is None:
subconfig = self.config.option
@ -294,9 +284,9 @@ class TiramisuCmdlineParser(ArgumentParser):
self.prog,
root=self.root,
remove_empty_od=self.remove_empty_od,
remove_empty_description_od=self.remove_empty_description_od,
formatter_class=self.formatter_class,
epilog=self.epilog,
description=self.description,
fullpath=self.fullpath)
namespace_, args_ = new_parser._parse_known_args(args_, new_parser.namespace)
else:
@ -555,9 +545,9 @@ class TiramisuCmdlineParser(ArgumentParser):
root=self.root,
fullpath=self.fullpath,
remove_empty_od=self.remove_empty_od,
remove_empty_description_od=self.remove_empty_description_od,
formatter_class=self.formatter_class,
epilog=self.epilog,
description=self.description,
_forhelp=True)
return super(TiramisuCmdlineParser, help_formatter).format_usage(*args, **kwargs)
@ -567,9 +557,9 @@ class TiramisuCmdlineParser(ArgumentParser):
root=self.root,
fullpath=self.fullpath,
remove_empty_od=self.remove_empty_od,
remove_empty_description_od=self.remove_empty_description_od,
formatter_class=self.formatter_class,
epilog=self.epilog,
description=self.description,
_forhelp=True)
return super(TiramisuCmdlineParser, help_formatter).format_help()