Skip to content

Commit bca9088

Browse files
committed
Merge pull request #43 from floGik/key_import
canmatrix.importany: accepts key for dict now thanks, looks good for me
2 parents ed0b56f + 56b6a70 commit bca9088

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

canmatrix/importany.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,29 @@
2828
def importany(infile, **options):
2929
# import within function to disable warning messages by log level
3030
from . import importall as im
31+
if "key" in options:
32+
key = options["key"]
33+
else:
34+
key = ""
3135
dbs = {}
3236
if infile[-3:] == 'dbc':
33-
dbs[""] = im.importDbc(infile, **options)
37+
dbs[key] = im.importDbc(infile, **options)
3438
elif infile[-3:] == 'dbf':
35-
dbs[""] = im.importDbf(infile, **options)
39+
dbs[key] = im.importDbf(infile, **options)
3640
elif infile[-3:] == 'sym':
37-
dbs[""] = im.importSym(infile, **options)
41+
dbs[key] = im.importSym(infile, **options)
3842
elif infile[-3:] == 'kcd':
39-
dbs[""] = im.importKcd(infile)
43+
dbs[key] = im.importKcd(infile)
4044
elif infile[-3:] == 'xls':
41-
dbs[""] = im.importXls(infile, **options)
45+
dbs[key] = im.importXls(infile, **options)
4246
elif infile[-4:] == 'xlsx' :
43-
dbs[""] = im.importXlsx(infile, **options)
47+
dbs[key] = im.importXlsx(infile, **options)
4448
elif infile[-5:] == 'arxml':
4549
dbs = im.importArxml(infile, **options)
4650
elif infile[-4:] == 'yaml':
47-
dbs[""] = im.importYaml(infile)
51+
dbs[key] = im.importYaml(infile)
4852
elif infile[-4:] == 'json':
49-
dbs[""] = im.importJson(infile)
53+
dbs[key] = im.importJson(infile)
5054
else:
5155
logger.error('\nFile not recognized: ' + infile + "\n")
5256
logger.info("done\n")

0 commit comments

Comments
 (0)