Skip to content

Commit

Permalink
Remove cm prefix (#236) (#399)
Browse files Browse the repository at this point in the history
Thanks
  • Loading branch information
Funth0mas authored and ebroecker committed Sep 18, 2019
1 parent d11c0d3 commit d373ff7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/canmatrix/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import StringIO

logger = logging.getLogger(__name__)
moduleList = ["arxml", "cmcsv", "dbc", "dbf", "cmjson",
moduleList = ["arxml", "csv", "dbc", "dbf", "json",
"kcd", "fibex", "sym", "xls", "xlsx", "yaml", "scapy"]
loadedFormats = []
supportedFormats = {} # type: typing.MutableMapping[str, typing.MutableSequence[str]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
logger = logging.getLogger(__name__)
CsvDataType = typing.Union[str, int]

extension = 'csv'


class CsvRow:
def __init__(self): # type: () -> None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

import canmatrix

extension = 'json'


def dump(db, f, **options):
# type: (canmatrix.CanMatrix, typing.BinaryIO, **str) -> None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_export_with_jsonall(default_matrix):
"""Check the jsonAll doesn't raise and export some additional field."""
matrix = default_matrix
out_file = io.BytesIO()
canmatrix.formats.dump(matrix, out_file, "cmjson", jsonAll=True)
canmatrix.formats.dump(matrix, out_file, "json", jsonAll=True)
data = out_file.getvalue().decode("utf-8")
assert "my_value1" in data
assert "my_value2" in data
Expand All @@ -42,7 +42,7 @@ def test_export_with_jsonall(default_matrix):
def test_export_additional_frame_info(default_matrix):
matrix = default_matrix
out_file = io.BytesIO()
canmatrix.formats.dump(matrix, out_file, "cmjson", additionalFrameAttributes="my_attribute1")
canmatrix.formats.dump(matrix, out_file, "json", additionalFrameAttributes="my_attribute1")
data = out_file.getvalue().decode("utf-8")
assert "my_value1" in data

Expand All @@ -57,7 +57,7 @@ def test_export_long_signal_names():
frame.add_signal(signal)

out_file = io.BytesIO()
canmatrix.formats.dump(matrix, out_file, "cmjson", jsonAll=True)
canmatrix.formats.dump(matrix, out_file, "json", jsonAll=True)
data = json.loads(out_file.getvalue().decode("utf-8"))

assert data['messages'][0]['signals'][0]['name'] == long_signal_name
Expand All @@ -70,7 +70,7 @@ def test_export_min_max():
frame.add_signal(signal)
matrix.add_frame(frame)
out_file = io.BytesIO()
canmatrix.formats.dump(matrix, out_file, "cmjson", jsonAll=True)
canmatrix.formats.dump(matrix, out_file, "json", jsonAll=True)
data = json.loads(out_file.getvalue().decode("utf-8"))
assert(data['messages'][0]['signals'][0]['min'] == '-5')
assert(data['messages'][0]['signals'][0]['max'] == '42')
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_import_min_max():
}
]
}"""
matrix = canmatrix.formats.loads_flat(json_input, "cmjson", jsonAll=True)
matrix = canmatrix.formats.loads_flat(json_input, "json", jsonAll=True)
assert matrix.frames[0].signals[0].min == -5
assert matrix.frames[0].signals[0].max == 42

Expand Down Expand Up @@ -140,7 +140,7 @@ def test_import_native():
}
]
}"""
matrix = canmatrix.formats.loads_flat(json_input, "cmjson", jsonAll=True)
matrix = canmatrix.formats.loads_flat(json_input, "json", jsonAll=True)
assert matrix.frames[0].signals[0].min == -4.2
assert matrix.frames[0].signals[0].max == 42
assert matrix.frames[0].signals[0].factor == 0.123
Expand All @@ -153,7 +153,7 @@ def test_export_native():
frame.add_signal(signal)
matrix.add_frame(frame)
out_file = io.BytesIO()
canmatrix.formats.dump(matrix, out_file, "cmjson", jsonNativeTypes=True)
canmatrix.formats.dump(matrix, out_file, "json", jsonNativeTypes=True)
data = json.loads(out_file.getvalue().decode("utf-8"))
assert (data['messages'][0]['signals'][0]['factor'] == 0.123)
assert (data['messages'][0]['signals'][0]['offset'] == 1)
Expand All @@ -165,7 +165,7 @@ def test_export_all_native():
frame.add_signal(signal)
matrix.add_frame(frame)
out_file = io.BytesIO()
canmatrix.formats.dump(matrix, out_file, "cmjson", jsonAll=True, jsonNativeTypes=True)
canmatrix.formats.dump(matrix, out_file, "json", jsonAll=True, jsonNativeTypes=True)
data = json.loads(out_file.getvalue().decode("utf-8"))
assert (data['messages'][0]['signals'][0]['min'] == -4.2)
assert (data['messages'][0]['signals'][0]['max'] == 42)
Expand Down

0 comments on commit d373ff7

Please sign in to comment.