Skip to content

Commit 2f3349b

Browse files
committed
revise __repr__ to produce a working function
- revise __repr__ to produce a working function - avoid a one line if statement - Indentation correction - Further revised indentation
1 parent 1e8490b commit 2f3349b

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

obd/OBDCommand.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,22 @@ def __str__(self):
122122
return "%s: %s" % (self.header + self.command, self.desc)
123123
return "%s: %s" % (self.command, self.desc)
124124

125-
def __repr(self):
126-
return "OBDCommand(%s, %s)" % (self.name, self.command)
125+
def __repr__(self):
126+
e = self.ecu
127+
if self.ecu == ECU.ALL:
128+
e = "ECU.ALL"
129+
if self.ecu == ECU.ENGINE:
130+
e = "ECU.ENGINE"
131+
if self.ecu == ECU.TRANSMISSION:
132+
e = "ECU.TRANSMISSION"
133+
if self.header == ECU_HEADER.ENGINE:
134+
return ("OBDCommand(%s, %s, %s, %s, raw_string, ecu=%s, fast=%s)"
135+
) % (repr(self.name), repr(self.desc), repr(self.command),
136+
self.bytes, e, self.fast)
137+
return ("OBDCommand" +
138+
"(%s, %s, %s, %s, raw_string, ecu=%s, fast=%s, header=%s)"
139+
) % (repr(self.name), repr(self.desc), repr(self.command),
140+
self.bytes, e, self.fast, repr(self.header))
127141

128142
def __hash__(self):
129143
# needed for using commands as keys in a dict (see async.py)

0 commit comments

Comments
 (0)