mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-11 01:10:37 +02:00
add documentation argument to parser_info and all_parser_info
This commit is contained in:
29
jc/lib.py
29
jc/lib.py
@ -1,7 +1,6 @@
|
||||
"""jc - JSON Convert
|
||||
JC lib module
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
@ -266,12 +265,18 @@ def streaming_parser_mod_list() -> List[str]:
|
||||
plist.append(_cliname_to_modname(p))
|
||||
return plist
|
||||
|
||||
def parser_info(parser_mod_name: str) -> Dict:
|
||||
def parser_info(parser_mod_name: str, documentation: bool = False) -> Dict:
|
||||
"""
|
||||
Returns a dictionary that includes the module metadata.
|
||||
Returns a dictionary that includes the parser module metadata.
|
||||
|
||||
This function will accept **module_name**, **cli-name**, and
|
||||
**--argument-name** variants of the module name string.
|
||||
Parameters:
|
||||
|
||||
parser_mod_name: (string) name of the parser module. This
|
||||
function will accept module_name,
|
||||
cli-name, and --argument-name
|
||||
variants of the module name.
|
||||
|
||||
documentation: (boolean) include parser docstring if True
|
||||
"""
|
||||
# ensure parser_mod_name is a true module name and not a cli name
|
||||
parser_mod_name = _cliname_to_modname(parser_mod_name)
|
||||
@ -291,13 +296,21 @@ def parser_info(parser_mod_name: str) -> Dict:
|
||||
if _modname_to_cliname(parser_mod_name) in local_parsers:
|
||||
info_dict['plugin'] = True
|
||||
|
||||
if documentation:
|
||||
info_dict['documentation'] = parser_mod.__doc__
|
||||
|
||||
return info_dict
|
||||
|
||||
def all_parser_info() -> List[Dict]:
|
||||
def all_parser_info(documentation: bool = False) -> List[Dict]:
|
||||
"""
|
||||
Returns a list of dictionaries that includes metadata for all modules.
|
||||
Returns a list of dictionaries that includes metadata for all parser
|
||||
modules.
|
||||
|
||||
Parameters:
|
||||
|
||||
documentation: (boolean) include parser docstrings if True
|
||||
"""
|
||||
return [parser_info(p) for p in parsers]
|
||||
return [parser_info(p, documentation=documentation) for p in parsers]
|
||||
|
||||
def get_help(parser_mod_name: str) -> None:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user