mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-09 01:05:53 +02:00
use get_parser instead of importlib
This commit is contained in:
@ -151,4 +151,4 @@ Source: [`jc/parsers/proc.py`](https://github.com/kellyjonbrazil/jc/blob/master/
|
|||||||
|
|
||||||
This parser can be used with the `--slurp` command-line option.
|
This parser can be used with the `--slurp` command-line option.
|
||||||
|
|
||||||
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -118,15 +118,15 @@ Examples:
|
|||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
import importlib
|
|
||||||
from typing import List, Dict, Union
|
from typing import List, Dict, Union
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
from jc.lib import get_parser
|
||||||
from jc.exceptions import ParseError
|
from jc.exceptions import ParseError
|
||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
version = '1.3'
|
version = '1.4'
|
||||||
description = '`/proc/` file parser'
|
description = '`/proc/` file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -280,7 +280,7 @@ def parse(
|
|||||||
for reg_pattern, parse_mod in procmap.items():
|
for reg_pattern, parse_mod in procmap.items():
|
||||||
if reg_pattern.search(data):
|
if reg_pattern.search(data):
|
||||||
try:
|
try:
|
||||||
procparser = importlib.import_module('jc.parsers.' + parse_mod)
|
procparser = get_parser(parse_mod)
|
||||||
return procparser.parse(data, quiet=quiet, raw=raw)
|
return procparser.parse(data, quiet=quiet, raw=raw)
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
raise ParseError('Proc file type not yet implemented.')
|
raise ParseError('Proc file type not yet implemented.')
|
||||||
|
Reference in New Issue
Block a user