Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if len(header)>0:
return header[0].rstrip()
return ''
def contenttype(self):
for item in str(self.contents).split('\n'):
ditem = item.split(":")
if ditem[0].strip().lower()=='content-type' and len(ditem)>1:
return ditem[1].strip()
return ''
def __str__(self):
return self.contents
class CustomHelpFormatter(configargparse.HelpFormatter):
"""
Class for customizing the help output
"""
def _format_action_invocation(self, action):
"""
Reformat multiple metavar output
-d , --device , --host
to single output
-d, --device, --host
"""
orgstr = configargparse.HelpFormatter._format_action_invocation(self, action)
if orgstr and orgstr[0] != '-': # only optional arguments
return orgstr
res = getattr(action, '_formatted_action_invocation', None)
def make_arg_parser(
description: str, plugins: List[PluginBase]
) -> configargparse.Parser:
class CustomHelpFormatter(configargparse.HelpFormatter):
def _format_action_invocation(
self, action: configargparse.Action
) -> str:
if not action.option_strings or action.nargs == 0:
return super()._format_action_invocation(action)
default = self._get_default_metavar_for_optional(action)
args_string = self._format_args(action, default)
return ", ".join(action.option_strings) + " " + args_string
class PluginAction(configargparse.Action):
def __call__(
self,
parser: configargparse.Parser,
args: configargparse.Namespace,
values: Any,
option_string=None,