mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-07 00:57:22 +02:00
Fix PEP 8: E302 violation as part of boy scout principle
This commit is contained in:
19
jc/lib.py
19
jc/lib.py
@ -239,14 +239,17 @@ parsers: List[str] = [
|
||||
'zpool-status'
|
||||
]
|
||||
|
||||
|
||||
def _cliname_to_modname(parser_cli_name: str) -> str:
|
||||
"""Return real module name (dashes converted to underscores)"""
|
||||
return parser_cli_name.replace('--', '').replace('-', '_')
|
||||
|
||||
|
||||
def _modname_to_cliname(parser_mod_name: str) -> str:
|
||||
"""Return module's cli name (underscores converted to dashes)"""
|
||||
return parser_mod_name.replace('_', '-')
|
||||
|
||||
|
||||
def _is_valid_parser_plugin(name: str, local_parsers_dir: str) -> bool:
|
||||
if re.match(r'\w+\.py$', name) and os.path.isfile(os.path.join(local_parsers_dir, name)):
|
||||
try:
|
||||
@ -283,11 +286,13 @@ if os.path.isdir(local_parsers_dir):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _parser_argument(parser_mod_name: str) -> str:
|
||||
"""Return short name of the parser with dashes and with -- prefix"""
|
||||
parser = _modname_to_cliname(parser_mod_name)
|
||||
return f'--{parser}'
|
||||
|
||||
|
||||
def get_parser(parser_mod_name: Union[str, ModuleType]) -> ModuleType:
|
||||
"""
|
||||
Return the parser module object and check that the module is a valid
|
||||
@ -327,6 +332,7 @@ def get_parser(parser_mod_name: Union[str, ModuleType]) -> ModuleType:
|
||||
|
||||
return jc_parser
|
||||
|
||||
|
||||
def _get_parser(parser_mod_name: str) -> ModuleType:
|
||||
"""Return the parser module object"""
|
||||
# ensure parser_mod_name is a true module name and not a cli name
|
||||
@ -344,6 +350,7 @@ def _get_parser(parser_mod_name: str) -> ModuleType:
|
||||
|
||||
return mod
|
||||
|
||||
|
||||
def _parser_is_slurpable(parser: ModuleType) -> bool:
|
||||
"""
|
||||
Returns True if this parser can use the `--slurp` command option, else False
|
||||
@ -356,6 +363,7 @@ def _parser_is_slurpable(parser: ModuleType) -> bool:
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def _parser_is_streaming(parser: ModuleType) -> bool:
|
||||
"""
|
||||
Returns True if this is a streaming parser, else False
|
||||
@ -367,6 +375,7 @@ def _parser_is_streaming(parser: ModuleType) -> bool:
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def _parser_is_hidden(parser: ModuleType) -> bool:
|
||||
"""
|
||||
Returns True if this is a hidden parser, else False
|
||||
@ -378,6 +387,7 @@ def _parser_is_hidden(parser: ModuleType) -> bool:
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def _parser_is_deprecated(parser: ModuleType) -> bool:
|
||||
"""
|
||||
Returns True if this is a deprecated parser, else False
|
||||
@ -389,6 +399,7 @@ def _parser_is_deprecated(parser: ModuleType) -> bool:
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def parse(
|
||||
parser_mod_name: Union[str, ModuleType],
|
||||
data: Union[str, bytes, Iterable[str]],
|
||||
@ -498,6 +509,7 @@ def parse(
|
||||
|
||||
return jc_parser.parse(data, quiet=quiet, raw=raw, **kwargs)
|
||||
|
||||
|
||||
def parser_mod_list(
|
||||
show_hidden: bool = False,
|
||||
show_deprecated: bool = False
|
||||
@ -517,6 +529,7 @@ def parser_mod_list(
|
||||
|
||||
return plist
|
||||
|
||||
|
||||
def plugin_parser_mod_list(
|
||||
show_hidden: bool = False,
|
||||
show_deprecated: bool = False
|
||||
@ -539,6 +552,7 @@ def plugin_parser_mod_list(
|
||||
|
||||
return plist
|
||||
|
||||
|
||||
def standard_parser_mod_list(
|
||||
show_hidden: bool = False,
|
||||
show_deprecated: bool = False
|
||||
@ -564,6 +578,7 @@ def standard_parser_mod_list(
|
||||
|
||||
return plist
|
||||
|
||||
|
||||
def streaming_parser_mod_list(
|
||||
show_hidden: bool = False,
|
||||
show_deprecated: bool = False
|
||||
@ -588,6 +603,7 @@ def streaming_parser_mod_list(
|
||||
|
||||
return plist
|
||||
|
||||
|
||||
def slurpable_parser_mod_list(
|
||||
show_hidden: bool = False,
|
||||
show_deprecated: bool = False
|
||||
@ -612,6 +628,7 @@ def slurpable_parser_mod_list(
|
||||
|
||||
return plist
|
||||
|
||||
|
||||
def parser_info(
|
||||
parser_mod_name: Union[str, ModuleType],
|
||||
documentation: bool = False
|
||||
@ -652,6 +669,7 @@ def parser_info(
|
||||
|
||||
return info_dict
|
||||
|
||||
|
||||
def all_parser_info(
|
||||
documentation: bool = False,
|
||||
show_hidden: bool = False,
|
||||
@ -686,6 +704,7 @@ def all_parser_info(
|
||||
|
||||
return p_info_list
|
||||
|
||||
|
||||
def get_help(parser_mod_name: Union[str, ModuleType]) -> None:
|
||||
"""
|
||||
Show help screen for the selected parser.
|
||||
|
Reference in New Issue
Block a user