Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cli_convert(infile, outfile, silent, verbosity, **options):
"""
canmatrix.cli.convert [options] import-file export-file
import-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym
export-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym|*.py
\n"""
root_logger = canmatrix.log.setup_logger()
if silent is True:
# only print error messages, ignore verbosity flag
verbosity = -1
options["silent"] = True
canmatrix.log.set_log_level(root_logger, verbosity)
if options["ignoreEncodingErrors"]:
options["ignoreEncodingErrors"] = "ignore"
else:
options["ignoreEncodingErrors"] = ""
canmatrix.convert.convert(infile, outfile, **options)
return 0
"""
canmatrix.cli.convert [options] import-file export-file
import-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym
export-file: *.dbc|*.dbf|*.kcd|*.arxml|*.json|*.xls(x)|*.sym|*.py
\n"""
root_logger = canmatrix.log.setup_logger()
if silent is True:
# only print error messages, ignore verbosity flag
verbosity = -1
options["silent"] = True
canmatrix.log.set_log_level(root_logger, verbosity)
if options["ignoreEncodingErrors"]:
options["ignoreEncodingErrors"] = "ignore"
else:
options["ignoreEncodingErrors"] = ""
canmatrix.convert.convert(infile, outfile, **options)
return 0
def cli_compare(matrix1, matrix2, verbosity, silent, check_comments, check_attributes, ignore_valuetables, frames):
"""
canmatrix.cli.compare [options] matrix1 matrix2
matrixX can be any of *.dbc|*.dbf|*.kcd|*.arxml|*.xls(x)|*.sym
"""
import canmatrix.log
root_logger = canmatrix.log.setup_logger()
if silent:
# Only print ERROR messages (ignore import warnings)
verbosity = -1
canmatrix.log.set_log_level(root_logger, verbosity)
# import only after setting log level, to also disable warning messages in silent mode.
import canmatrix.formats # due this import we need the import alias for log module
logger.info("Importing " + matrix1 + " ... ")
db1 = canmatrix.formats.loadp_flat(matrix1)
logger.info("%d Frames found" % (db1.frames.__len__()))
logger.info("Importing " + matrix2 + " ... ")
db2 = canmatrix.formats.loadp_flat(matrix2)
logger.info("%d Frames found" % (db2.frames.__len__()))
ignore = {} # type: typing.Dict[str, typing.Union[str, bool]]
if not check_comments:
ignore["comment"] = "*"
def cli_compare(matrix1, matrix2, verbosity, silent, check_comments, check_attributes, ignore_valuetables, frames):
"""
canmatrix.cli.compare [options] matrix1 matrix2
matrixX can be any of *.dbc|*.dbf|*.kcd|*.arxml|*.xls(x)|*.sym
"""
import canmatrix.log
root_logger = canmatrix.log.setup_logger()
if silent:
# Only print ERROR messages (ignore import warnings)
verbosity = -1
canmatrix.log.set_log_level(root_logger, verbosity)
# import only after setting log level, to also disable warning messages in silent mode.
import canmatrix.formats # due this import we need the import alias for log module
logger.info("Importing " + matrix1 + " ... ")
db1 = canmatrix.formats.loadp_flat(matrix1)
logger.info("%d Frames found" % (db1.frames.__len__()))
logger.info("Importing " + matrix2 + " ... ")
db2 = canmatrix.formats.loadp_flat(matrix2)
logger.info("%d Frames found" % (db2.frames.__len__()))