26
26
import sys
27
27
import typing
28
28
29
- import canmatrix . canmatrix as cm
29
+ import canmatrix
30
30
import canmatrix .copy
31
31
import canmatrix .formats
32
32
import canmatrix .log
@@ -42,25 +42,25 @@ def convert(infile, out_file_name, **options): # type: (str, str, **str) -> Non
42
42
43
43
logger .info ("Exporting " + out_file_name + " ... " )
44
44
45
- out_dbs = {}
45
+ out_dbs = {} # type: typing.Dict[str, canmatrix.CanMatrix]
46
46
for name in dbs :
47
47
db = None
48
48
49
49
if 'ecus' in options and options ['ecus' ] is not None :
50
50
ecu_list = options ['ecus' ].split (',' )
51
- db = cm .CanMatrix ()
51
+ db = canmatrix .CanMatrix ()
52
52
for ecu in ecu_list :
53
53
canmatrix .copy .copy_ecu_with_frames (ecu , dbs [name ], db )
54
54
if 'frames' in options and options ['frames' ] is not None :
55
55
frame_list = options ['frames' ].split (',' )
56
- db = cm .CanMatrix ()
57
- for frame_name in frame_list : # type: str
58
- frame_to_copy = dbs [name ].frame_by_name (frame_name ) # type: cm.Frame
56
+ db = canmatrix .CanMatrix ()
57
+ for frame_name in frame_list :
58
+ frame_to_copy = dbs [name ].frame_by_name (frame_name )
59
59
canmatrix .copy .copy_frame (frame_to_copy .arbitration_id , dbs [name ], db )
60
60
if options .get ('signals' , False ):
61
61
signal_list = options ['signals' ].split (',' )
62
- db = cm .CanMatrix ()
63
- for signal_name in signal_list : # type: str
62
+ db = canmatrix .CanMatrix ()
63
+ for signal_name in signal_list :
64
64
canmatrix .copy .copy_signal (signal_name , dbs [name ], db )
65
65
66
66
if db is None :
@@ -110,8 +110,8 @@ def convert(infile, out_file_name, **options): # type: (str, str, **str) -> Non
110
110
for touple in touples :
111
111
(frameName , ecu ) = touple .split (':' )
112
112
frames = db .glob_frames (frameName )
113
- for frame in frames : # type: cm.Frame
114
- for signal in frame .signals : # type: cm.Signal
113
+ for frame in frames :
114
+ for signal in frame .signals :
115
115
signal .add_receiver (ecu )
116
116
frame .update_receiver ()
117
117
@@ -123,7 +123,7 @@ def convert(infile, out_file_name, **options): # type: (str, str, **str) -> Non
123
123
change_tuples = options ['changeFrameId' ].split (',' )
124
124
for renameTuple in change_tuples :
125
125
old , new = renameTuple .split (':' )
126
- frame = db .frame_by_id (cm .ArbitrationId (int (old )))
126
+ frame = db .frame_by_id (canmatrix .ArbitrationId (int (old )))
127
127
if frame is not None :
128
128
frame .arbitration_id .id = int (new )
129
129
else :
@@ -144,20 +144,22 @@ def convert(infile, out_file_name, **options): # type: (str, str, **str) -> Non
144
144
frame_ptr .del_attribute ("VFrameFormat" )
145
145
146
146
if 'skipLongDlc' in options and options ['skipLongDlc' ] is not None :
147
- delete_frame_list = [] # type: typing.List[cm.Frame]
148
- for frame in db .frames :
149
- if frame .size > int (options ['skipLongDlc' ]):
150
- delete_frame_list .append (frame )
147
+ delete_frame_list = [
148
+ frame
149
+ for frame in db .frames
150
+ if frame .size > int (options ['skipLongDlc' ])
151
+ ]
151
152
for frame in delete_frame_list :
152
153
db .del_frame (frame )
153
154
154
155
if 'cutLongFrames' in options and options ['cutLongFrames' ] is not None :
155
156
for frame in db .frames :
156
157
if frame .size > int (options ['cutLongFrames' ]):
157
- delete_signal_list = []
158
- for sig in frame .signals :
159
- if sig .get_startbit () + int (sig .size ) > int (options ['cutLongFrames' ])* 8 :
160
- delete_signal_list .append (sig )
158
+ delete_signal_list = [
159
+ sig
160
+ for sig in frame .signals
161
+ if sig .get_startbit () + int (sig .size ) > int (options ['cutLongFrames' ])* 8
162
+ ]
161
163
for sig in delete_signal_list :
162
164
frame .signals .remove (sig )
163
165
frame .size = 0
0 commit comments