Skip to content

Commit a303dff

Browse files
Funth0masebroecker
authored andcommitted
Make classes upper case again (#298)
* Make classes upper case
1 parent fa7a825 commit a303dff

9 files changed

+33
-33
lines changed

src/canmatrix/canmatrix.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class ExceptionTemplate(Exception):
5555
def __call__(self, *args):
5656
return self.__class__(*(self.args + args))
5757

58-
class StarbitLowerZero(ExceptionTemplate): pass
58+
class StartbitLowerZero(ExceptionTemplate): pass
5959
class EncodingComplexMultiplexed(ExceptionTemplate): pass
6060
class MissingMuxSignal(ExceptionTemplate): pass
6161
class DecodingComplexMultiplexed(ExceptionTemplate): pass
6262
class DecodingFrameLength(ExceptionTemplate): pass
6363

6464
@attr.s
65-
class ecu(object):
65+
class Ecu(object):
6666
"""
6767
Contains one Boardunit/ECU
6868
"""
@@ -295,7 +295,7 @@ def set_startbit(self, start_bit, bitNumbering=None, startLittle=None):
295295
if start_bit < 0:
296296
print("wrong start_bit found Signal: %s Startbit: %d" %
297297
(self.name, start_bit))
298-
raise StarbitLowerZero
298+
raise StartbitLowerZero
299299
self.start_bit = start_bit
300300

301301
def get_startbit(self, bit_numbering=None, start_little=None):
@@ -418,7 +418,7 @@ def __str__(self):
418418

419419

420420
@attr.s(cmp=False)
421-
class signal_group(object):
421+
class SignalGroup(object):
422422
"""
423423
Represents signal-group, containing multiple Signals.
424424
"""
@@ -467,7 +467,7 @@ def __getitem__(self, name):
467467

468468

469469
@attr.s
470-
class decoded_signal(object):
470+
class DecodedSignal(object):
471471
"""
472472
Contains a decoded signal (frame decoding)
473473
@@ -691,7 +691,7 @@ def add_signal_group(self, Name, Id, signalNames):
691691
:param int Id: Group id
692692
:param list of str signalNames: list of Signal names to add. Non existing names are ignored.
693693
"""
694-
newGroup = signal_group(Name, Id)
694+
newGroup = SignalGroup(Name, Id)
695695
self.signalGroups.append(newGroup)
696696
for signal in signalNames:
697697
signal = signal.strip()
@@ -706,7 +706,7 @@ def signal_group_by_name(self, name):
706706
707707
:param str name: group name
708708
:return: SignalGroup by name or None if not found.
709-
:rtype: signal_group
709+
:rtype: SignalGroup
710710
"""
711711
for signalGroup in self.signalGroups:
712712
if signalGroup.name == name:
@@ -1010,7 +1010,7 @@ def unpack(self, data, report_error=True):
10101010
returnDict= dict()
10111011

10121012
for s, v in zip(self.signals, unpacked):
1013-
returnDict[s.name] = decoded_signal(v, s)
1013+
returnDict[s.name] = DecodedSignal(v, s)
10141014

10151015
return returnDict
10161016

@@ -1372,7 +1372,7 @@ def ecu_by_name(self, name):
13721372
Returns Boardunit by Name.
13731373
13741374
:param str name: BoardUnit name
1375-
:rtype: ecu or None
1375+
:rtype: Ecu or None
13761376
"""
13771377
for test in self.ecus:
13781378
if test.name == name:
@@ -1384,7 +1384,7 @@ def glob_ecus(self, globStr):
13841384
Find ECUs by given glob pattern.
13851385
13861386
:param globStr: glob pattern to filter BoardUnits. See `fnmatch.fnmatchcase`.
1387-
:rtype: list of ecu
1387+
:rtype: list of Ecu
13881388
"""
13891389
returnArray = []
13901390
for test in self.ecus:
@@ -1470,7 +1470,7 @@ def recalc_dlc(self, strategy):
14701470
def rename_ecu(self, old, newName):
14711471
"""Rename ECU in the Matrix. Update references in all Frames.
14721472
1473-
:param str or ecu old: old name or ECU instance
1473+
:param str or Ecu old: old name or ECU instance
14741474
:param str newName: new name
14751475
"""
14761476
if type(old).__name__ == 'instance':
@@ -1494,7 +1494,7 @@ def rename_ecu(self, old, newName):
14941494
def add_ecu(self, ecu):
14951495
"""Add new ECU to the Matrix. Do nothing if ecu with the same name already exists.
14961496
1497-
:param ecu ecu: ECU name to add
1497+
:param Ecu ecu: ECU name to add
14981498
"""
14991499
for bu in self.ecus:
15001500
if bu.name.strip() == ecu.name:
@@ -1504,7 +1504,7 @@ def add_ecu(self, ecu):
15041504
def del_ecu(self, ecu):
15051505
"""Remove ECU from Matrix and all Frames.
15061506
1507-
:param str or ecu ecu: ECU instance or glob pattern to remove from list
1507+
:param str or Ecu ecu: ECU instance or glob pattern to remove from list
15081508
"""
15091509
if type(ecu).__name__ == 'instance':
15101510
ecuList = [ecu]
@@ -1526,11 +1526,11 @@ def update_ecu_list(self):
15261526
"""Check all Frames and add unknown ECUs to the Matrix ECU list."""
15271527
for frame in self.frames:
15281528
for transmit_ecu in frame.transmitters:
1529-
self.add_ecu(canmatrix.ecu(transmit_ecu))
1529+
self.add_ecu(canmatrix.Ecu(transmit_ecu))
15301530
frame.update_receiver()
15311531
for signal in frame.signals:
15321532
for receive_ecu in signal.receivers:
1533-
self.add_ecu(canmatrix.ecu(receive_ecu))
1533+
self.add_ecu(canmatrix.Ecu(receive_ecu))
15341534

15351535
def rename_frame(self, old, newName):
15361536
"""Rename Frame.

src/canmatrix/dbc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ class FollowUps(object):
702702
myTempListe = temp.group(1).split(' ')
703703
for ele in myTempListe:
704704
if len(ele.strip()) > 1:
705-
db.ecus.append(canmatrix.ecu(ele))
705+
db.ecus.append(canmatrix.Ecu(ele))
706706

707707
elif decoded.startswith("VAL_ "):
708708
regexp = re.compile(r"^VAL_ +(\w+) +(\w+) +(.*);")

src/canmatrix/dbf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def load(f, **options):
231231
temstr = line.strip()[6:].strip()
232232
boList = temstr.split(',')
233233
for bo in boList:
234-
db.add_ecu(ecu(bo))
234+
db.add_ecu(Ecu(bo))
235235

236236
if line.startswith("[START_SIGNALS]"):
237237
temstr = line.strip()[15:].strip()

src/canmatrix/kcd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def load(f, **options):
351351
db = canmatrix.CanMatrix()
352352
db.add_frame_defines("GenMsgCycleTime", 'INT 0 65535')
353353
for node in nodes:
354-
db.BUs.add(canmatrix.ecu(node.get('name')))
354+
db.BUs.add(canmatrix.Ecu(node.get('name')))
355355
nodelist[node.get('id')] = node.get('name')
356356

357357
messages = bus.findall('./' + namespace + 'Message')

src/canmatrix/tests/test_canmatrix.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ def test_decode_signal():
119119

120120
# BoardUnit
121121
def test_ecu_find_attribute():
122-
ecu = canmatrix.canmatrix.ecu(name="Gateway")
122+
ecu = canmatrix.canmatrix.Ecu(name="Gateway")
123123
ecu.add_attribute("attr1", 255)
124124
assert ecu.attribute("attr1") == 255
125125

126126

127127
def test_ecu_no_attribute():
128-
ecu = canmatrix.canmatrix.ecu(name="Gateway")
128+
ecu = canmatrix.canmatrix.Ecu(name="Gateway")
129129
assert ecu.attribute("wrong") is None
130130
assert ecu.attribute("wrong", default=0) == 0
131131

132132

133133
def test_ecu_default_attr_from_db():
134-
ecu = canmatrix.canmatrix.ecu(name="Gateway")
134+
ecu = canmatrix.canmatrix.Ecu(name="Gateway")
135135
define = canmatrix.canmatrix.Define("INT 0 255")
136136
define.defaultValue = 33
137137
matrix = canmatrix.canmatrix.CanMatrix(ecu_defines={"temperature": define})
@@ -140,9 +140,9 @@ def test_ecu_default_attr_from_db():
140140

141141

142142
def test_ecu_repr():
143-
ecu = canmatrix.canmatrix.ecu(name="Gateway")
143+
ecu = canmatrix.canmatrix.Ecu(name="Gateway")
144144
ecu.add_comment("with bug")
145-
assert str(ecu) == "ecu(name='Gateway', comment='with bug')"
145+
assert str(ecu) == "Ecu(name='Gateway', comment='with bug')"
146146

147147

148148
# Signal (generic functions)
@@ -351,7 +351,7 @@ def test_signal_range_type_float():
351351
# SignalGroup
352352
@pytest.fixture
353353
def the_group():
354-
return canmatrix.canmatrix.signal_group(name="TestGroup", id=1)
354+
return canmatrix.canmatrix.SignalGroup(name="TestGroup", id=1)
355355

356356

357357
@pytest.fixture
@@ -695,11 +695,11 @@ def test_canid_repr():
695695
# DecodedSignal tests
696696
def test_decoded_signal_phys_value(some_signal):
697697
signal = canmatrix.canmatrix.Signal(factor="0.1", values={10: "Init"})
698-
decoded = canmatrix.canmatrix.decoded_signal(100, signal)
698+
decoded = canmatrix.canmatrix.DecodedSignal(100, signal)
699699
assert decoded.phys_value == decimal.Decimal("10")
700700

701701

702702
def test_decoded_signal_named_value():
703703
signal = canmatrix.canmatrix.Signal(factor="0.1", values={10: "Init"})
704-
decoded = canmatrix.canmatrix.decoded_signal(100, signal)
704+
decoded = canmatrix.canmatrix.DecodedSignal(100, signal)
705705
assert decoded.named_value == "Init"

src/canmatrix/xls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def load(file, **options):
396396

397397
# BoardUnits:
398398
for x in range(index['BUstart'], index['BUend']):
399-
db.add_ecu(canmatrix.ecu(sh.cell(0, x).value))
399+
db.add_ecu(canmatrix.Ecu(sh.cell(0, x).value))
400400

401401
# initialize:
402402
frameId = None

src/canmatrix/xlsx.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def load(filename, **options):
434434
motorolaBitFormat = "msbreverse"
435435

436436
sheet = readXlsx(filename, sheet=1, header=True)
437-
db = canmarix.CanMatrix()
437+
db = canmatrix.CanMatrix()
438438
letterIndex = []
439439
for a in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
440440
letterIndex.append(a)
@@ -467,7 +467,7 @@ def load(filename, **options):
467467

468468
# BoardUnits:
469469
for x in range(_BUstart, _BUend):
470-
db.add_ecu(canmatrix.ecu(sheet[0][letterIndex[x]]))
470+
db.add_ecu(canmatrix.Ecu(sheet[0][letterIndex[x]]))
471471

472472
# initialize:
473473
frameId = None

test/createTestFdMatrix.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
db = canmatrix.CanMatrix()
1313

14-
db.ecus.add(canmatrix.ecu("testBU"))
15-
db.ecus.add(canmatrix.ecu("recBU"))
14+
db.ecus.add(canmatrix.Ecu("testBU"))
15+
db.ecus.add(canmatrix.Ecu("recBU"))
1616

1717
myFrame1 = canmatrix.Frame("canFdStandard1",Id=1, dlc=24, is_fd = True, transmitter=["testBU"])
1818
myFrame2 = canmatrix.Frame("CanFdExtended2",Id=2, dlc=16, extended = True, is_fd = True, transmitter=["testBU"])

test/createTestMatrix.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
db = CanMatrix()
1414

15-
db.ecus.add(ecu("testBU"))
16-
db.ecus.add(ecu("recBU"))
15+
db.ecus.add(Ecu("testBU"))
16+
db.ecus.add(Ecu("recBU"))
1717

1818
myFrame = Frame("testFrame1", Id=0x123, dlc=8, transmitter="testBU")
1919

0 commit comments

Comments
 (0)