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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
output_line = {}
|
||||
|
@ -130,8 +130,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -166,8 +166,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -103,8 +103,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -225,8 +225,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
cleandata = data.splitlines()
|
||||
|
@ -220,8 +220,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
cleandata = data.splitlines()
|
||||
|
@ -119,8 +119,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -115,8 +115,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -203,9 +203,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
fix_data = []
|
||||
|
@ -528,9 +528,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -173,8 +173,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -177,8 +177,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
item_header = False
|
||||
item_values = False
|
||||
|
@ -217,8 +217,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
working_list = []
|
||||
raw_output = []
|
||||
|
@ -137,8 +137,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -121,8 +121,8 @@ def parse(data, raw=False, quiet=False):
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -106,8 +106,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -168,8 +168,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -86,8 +86,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -122,8 +122,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
|
@ -132,8 +132,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -160,8 +160,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -126,8 +126,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
cleandata = data.splitlines()
|
||||
|
@ -85,8 +85,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
|
@ -113,8 +113,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -372,8 +372,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
device_object = {}
|
||||
|
@ -109,8 +109,8 @@ def parse(data, raw=False, quiet=False):
|
||||
Dictionary of raw structured data or
|
||||
List of Dictionaries of processed structured data
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -117,8 +117,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -161,8 +161,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -474,8 +474,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -125,8 +125,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary representing the ini file
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -240,8 +240,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
chain = {}
|
||||
|
@ -293,8 +293,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
section = {}
|
||||
|
@ -141,8 +141,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -185,8 +185,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -162,8 +162,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
warned = False
|
||||
|
@ -321,8 +321,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
# Clear any blank lines
|
||||
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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
|
@ -168,8 +168,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -815,8 +815,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
lsusb = _LsUsb()
|
||||
|
||||
|
@ -163,8 +163,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
# Clear any blank lines
|
||||
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.
|
||||
"""
|
||||
import jc.utils
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = list(filter(None, data.splitlines()))
|
||||
raw_output = []
|
||||
|
@ -264,8 +264,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
|
@ -142,8 +142,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -616,8 +616,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -91,8 +91,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -108,8 +108,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
package = {}
|
||||
|
@ -276,8 +276,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()
|
||||
raw_output = []
|
||||
|
@ -180,8 +180,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
|
||||
|
@ -216,8 +216,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
entry_obj = {}
|
||||
|
@ -265,8 +265,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
item = {}
|
||||
|
@ -149,8 +149,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -337,8 +337,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
contains_colon = ['nl', 'p_raw', 'raw', 'udp', 'tcp', 'v_str', 'icmp6']
|
||||
raw_output = []
|
||||
|
@ -229,8 +229,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -105,8 +105,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -101,8 +101,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
# Clear any blank lines
|
||||
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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
# Clear any blank lines
|
||||
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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
# Clear any blank lines
|
||||
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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
# Clear any blank lines
|
||||
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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
delim = ":" # k/v delimiter
|
||||
raw_data = {} # intermediary output
|
||||
|
@ -198,8 +198,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -116,8 +116,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -192,8 +192,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
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_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.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -394,8 +394,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
rules_list = []
|
||||
|
@ -265,8 +265,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
item_obj = {}
|
||||
|
@ -91,8 +91,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
|
||||
|
@ -323,8 +323,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
device_obj = {}
|
||||
|
@ -155,8 +155,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
Dictionary. Raw or processed structured data
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = {}
|
||||
cleandata = data.splitlines()
|
||||
|
@ -181,8 +181,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
output_line = {}
|
||||
|
@ -153,8 +153,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
cleandata = data.splitlines()[1:]
|
||||
raw_output = []
|
||||
|
@ -103,8 +103,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -186,8 +186,8 @@ def parse(data, raw=False, quiet=False):
|
||||
|
||||
List of Dictionaries. Raw or processed structured data.
|
||||
"""
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -121,8 +121,8 @@ def parse(data, raw=False, quiet=False):
|
||||
except Exception:
|
||||
raise LibraryNotInstalled('The xmltodict library is not installed.')
|
||||
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
@ -135,8 +135,8 @@ def parse(data, raw=False, quiet=False):
|
||||
except Exception:
|
||||
raise LibraryNotInstalled('The ruamel.yaml library is not installed.')
|
||||
|
||||
if not quiet: jc.utils.compatibility(__name__, info.compatible)
|
||||
if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.")
|
||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||
jc.utils.input_type_check(data)
|
||||
|
||||
raw_output = []
|
||||
|
||||
|
40
jc/utils.py
40
jc/utils.py
@ -75,7 +75,7 @@ def error_message(message_lines):
|
||||
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.
|
||||
|
||||
Parameters:
|
||||
@ -86,22 +86,25 @@ def compatibility(mod_name, compatible):
|
||||
compatible options:
|
||||
linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
quiet: (bool) supress compatibility message if True
|
||||
|
||||
Returns:
|
||||
|
||||
None - just prints output to STDERR
|
||||
"""
|
||||
platform_found = False
|
||||
if not quiet:
|
||||
platform_found = False
|
||||
|
||||
for platform in compatible:
|
||||
if sys.platform.startswith(platform):
|
||||
platform_found = True
|
||||
break
|
||||
for platform in compatible:
|
||||
if sys.platform.startswith(platform):
|
||||
platform_found = True
|
||||
break
|
||||
|
||||
if not platform_found:
|
||||
mod = mod_name.split('.')[-1]
|
||||
compat_list = ', '.join(compatible)
|
||||
warning_message([f'{mod} parser not compatible with your OS ({sys.platform}).',
|
||||
f'Compatible platforms: {compat_list}'])
|
||||
if not platform_found:
|
||||
mod = mod_name.split('.')[-1]
|
||||
compat_list = ', '.join(compatible)
|
||||
warning_message([f'{mod} parser not compatible with your OS ({sys.platform}).',
|
||||
f'Compatible platforms: {compat_list}'])
|
||||
|
||||
|
||||
def has_data(data):
|
||||
@ -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:
|
||||
"""
|
||||
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