mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
use jc.utils.input_type_check() and simplify compatibility check
This commit is contained in:
@ -302,8 +302,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
output_line = {}
|
output_line = {}
|
||||||
|
@ -130,8 +130,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -166,8 +166,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = list(filter(None, data.splitlines()))
|
cleandata = list(filter(None, data.splitlines()))
|
||||||
|
@ -171,8 +171,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = list(filter(None, data.splitlines()))
|
cleandata = list(filter(None, data.splitlines()))
|
||||||
|
@ -176,8 +176,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -225,8 +225,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -220,8 +220,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -119,8 +119,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -115,8 +115,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -203,9 +203,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.input_type_check(data)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
fix_data = []
|
fix_data = []
|
||||||
|
@ -528,9 +528,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.input_type_check(data)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -173,8 +173,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -177,8 +177,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
item_header = False
|
item_header = False
|
||||||
item_values = False
|
item_values = False
|
||||||
|
@ -217,8 +217,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
working_list = []
|
working_list = []
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -137,8 +137,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
Dictionary of raw structured data or
|
Dictionary of raw structured data or
|
||||||
List of Dictionaries of processed structured data
|
List of Dictionaries of processed structured data
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -132,8 +132,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -160,8 +160,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -126,8 +126,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -85,8 +85,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -113,8 +113,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -372,8 +372,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
device_object = {}
|
device_object = {}
|
||||||
|
@ -109,8 +109,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
Dictionary of raw structured data or
|
Dictionary of raw structured data or
|
||||||
List of Dictionaries of processed structured data
|
List of Dictionaries of processed structured data
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -161,8 +161,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -474,8 +474,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -125,8 +125,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary representing the ini file
|
Dictionary representing the ini file
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -240,8 +240,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
chain = {}
|
chain = {}
|
||||||
|
@ -293,8 +293,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
section = {}
|
section = {}
|
||||||
|
@ -141,8 +141,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -185,8 +185,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -162,8 +162,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
warned = False
|
warned = False
|
||||||
|
@ -321,8 +321,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
cleandata = list(filter(None, data.splitlines()))
|
cleandata = list(filter(None, data.splitlines()))
|
||||||
|
@ -174,8 +174,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -168,8 +168,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -815,8 +815,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
lsusb = _LsUsb()
|
lsusb = _LsUsb()
|
||||||
|
|
||||||
|
@ -163,8 +163,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
cleandata = list(filter(None, data.splitlines()))
|
cleandata = list(filter(None, data.splitlines()))
|
||||||
|
@ -424,8 +424,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = list(filter(None, data.splitlines()))
|
cleandata = list(filter(None, data.splitlines()))
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -264,8 +264,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -142,8 +142,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -616,8 +616,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
package = {}
|
package = {}
|
||||||
|
@ -276,8 +276,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -180,8 +180,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = data.splitlines()[1:]
|
cleandata = data.splitlines()[1:]
|
||||||
|
|
||||||
|
@ -216,8 +216,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
entry_obj = {}
|
entry_obj = {}
|
||||||
|
@ -265,8 +265,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
item = {}
|
item = {}
|
||||||
|
@ -149,8 +149,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -337,8 +337,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
contains_colon = ['nl', 'p_raw', 'raw', 'udp', 'tcp', 'v_str', 'icmp6']
|
contains_colon = ['nl', 'p_raw', 'raw', 'udp', 'tcp', 'v_str', 'icmp6']
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -229,8 +229,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -105,8 +105,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -101,8 +101,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
linedata = list(filter(None, data.splitlines()))
|
linedata = list(filter(None, data.splitlines()))
|
||||||
|
@ -123,8 +123,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
linedata = list(filter(None, data.splitlines()))
|
linedata = list(filter(None, data.splitlines()))
|
||||||
|
@ -93,8 +93,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
linedata = list(filter(None, data.splitlines()))
|
linedata = list(filter(None, data.splitlines()))
|
||||||
|
@ -89,8 +89,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
# Clear any blank lines
|
# Clear any blank lines
|
||||||
linedata = list(filter(None, data.splitlines()))
|
linedata = list(filter(None, data.splitlines()))
|
||||||
|
@ -303,8 +303,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
delim = ":" # k/v delimiter
|
delim = ":" # k/v delimiter
|
||||||
raw_data = {} # intermediary output
|
raw_data = {} # intermediary output
|
||||||
|
@ -198,8 +198,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -192,8 +192,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
RE_TTL_HOST = re.compile(r'^\s?(?P<ttl>\d+)(?P<ttl_guess>\??):\s+(?P<host>(?:no reply|\S+))') # groups: ttl, ttl_guess, host
|
RE_TTL_HOST = re.compile(r'^\s?(?P<ttl>\d+)(?P<ttl_guess>\??):\s+(?P<host>(?:no reply|\S+))') # groups: ttl, ttl_guess, host
|
||||||
RE_PMTU = re.compile(r'\spmtu\s(?P<pmtu>[\d]+)') # group: pmtu
|
RE_PMTU = re.compile(r'\spmtu\s(?P<pmtu>[\d]+)') # group: pmtu
|
||||||
|
@ -368,8 +368,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -394,8 +394,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
rules_list = []
|
rules_list = []
|
||||||
|
@ -265,8 +265,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
item_obj = {}
|
item_obj = {}
|
||||||
|
@ -91,8 +91,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
Dictionary. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
|
|
||||||
|
@ -323,8 +323,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
device_obj = {}
|
device_obj = {}
|
||||||
|
@ -155,8 +155,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
Dictionary. Raw or processed structured data
|
Dictionary. Raw or processed structured data
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = {}
|
raw_output = {}
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
|
@ -181,8 +181,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
output_line = {}
|
output_line = {}
|
||||||
|
@ -153,8 +153,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
cleandata = data.splitlines()[1:]
|
cleandata = data.splitlines()[1:]
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
@ -103,8 +103,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -186,8 +186,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
List of Dictionaries. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise LibraryNotInstalled('The xmltodict library is not installed.')
|
raise LibraryNotInstalled('The xmltodict library is not installed.')
|
||||||
|
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
@ -135,8 +135,8 @@ def parse(data, raw=False, quiet=False):
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise LibraryNotInstalled('The ruamel.yaml library is not installed.')
|
raise LibraryNotInstalled('The ruamel.yaml library is not installed.')
|
||||||
|
|
||||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output = []
|
raw_output = []
|
||||||
|
|
||||||
|
20
jc/utils.py
20
jc/utils.py
@ -75,7 +75,7 @@ def error_message(message_lines):
|
|||||||
print(message, file=sys.stderr)
|
print(message, file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def compatibility(mod_name, compatible):
|
def compatibility(mod_name, compatible, quiet=False):
|
||||||
"""Checks for the parser's compatibility with the running OS platform.
|
"""Checks for the parser's compatibility with the running OS platform.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@ -86,10 +86,13 @@ def compatibility(mod_name, compatible):
|
|||||||
compatible options:
|
compatible options:
|
||||||
linux, darwin, cygwin, win32, aix, freebsd
|
linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
|
quiet: (bool) supress compatibility message if True
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
None - just prints output to STDERR
|
None - just prints output to STDERR
|
||||||
"""
|
"""
|
||||||
|
if not quiet:
|
||||||
platform_found = False
|
platform_found = False
|
||||||
|
|
||||||
for platform in compatible:
|
for platform in compatible:
|
||||||
@ -235,6 +238,21 @@ def stream_error(e, ignore_exceptions, line):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def input_type_check(data):
|
||||||
|
if not isinstance(data, str):
|
||||||
|
raise TypeError("Input data must be a 'str' object.")
|
||||||
|
|
||||||
|
|
||||||
|
def streaming_input_type_check(data):
|
||||||
|
if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)):
|
||||||
|
raise TypeError("Input data must be a non-string iterable object.")
|
||||||
|
|
||||||
|
|
||||||
|
def streaming_line_input_type_check(line):
|
||||||
|
if not isinstance(line, str):
|
||||||
|
raise TypeError("Input line must be a 'str' object.")
|
||||||
|
|
||||||
|
|
||||||
class timestamp:
|
class timestamp:
|
||||||
"""
|
"""
|
||||||
Input a date-time text string of several formats and convert to a naive or timezone-aware epoch timestamp in UTC
|
Input a date-time text string of several formats and convert to a naive or timezone-aware epoch timestamp in UTC
|
||||||
|
Reference in New Issue
Block a user