Skip to content

Commit 07136dd

Browse files
author
Brendan Whitfield
committed
merged updates for python 3 compatibility, updated new files as well
2 parents 814f48d + ce8bdd8 commit 07136dd

13 files changed

Lines changed: 42 additions & 40 deletions

File tree

obd/OBDCommand.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
########################################################################
3131

3232
import re
33-
from utils import *
34-
from debug import debug
33+
from .utils import *
34+
from .debug import debug
3535

3636

3737
class OBDCommand():

obd/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232
__version__ = '0.3.0'
3333

34-
from obd import OBD
35-
from OBDCommand import OBDCommand
36-
from commands import commands
37-
from utils import scanSerial, Unit
38-
from debug import debug
39-
from async import Async
34+
from .obd import OBD
35+
from .OBDCommand import OBDCommand
36+
from .commands import commands
37+
from .utils import scanSerial, Unit
38+
from .debug import debug
39+
from .async import Async

obd/async.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@
2929
# #
3030
########################################################################
3131

32-
import obd
3332
import time
3433
import threading
35-
from utils import Response
36-
from commands import OBDCommand
37-
from debug import debug
34+
from .utils import Response
35+
from .debug import debug
36+
from . import OBD
3837

39-
40-
41-
class Async(obd.OBD):
38+
class Async(OBD):
4239
""" subclass representing an OBD-II connection """
4340

4441
def __init__(self, portstr=None):
@@ -86,7 +83,7 @@ def watch(self, c, callback=None, force=False):
8683
return
8784

8885
# new command being watched, store the command
89-
if not self.commands.has_key(c):
86+
if c not in self.commands:
9087
debug("Watching command: %s" % str(c))
9188
self.commands[c] = Response() # give it an initial value
9289
self.callbacks[c] = [] # create an empty list
@@ -131,7 +128,7 @@ def unwatch_all(self):
131128

132129

133130
def query(self, c):
134-
if self.commands.has_key(c):
131+
if c in self.commands:
135132
return self.commands[c]
136133
else:
137134
return Response()

obd/commands.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
# #
3030
########################################################################
3131

32-
from OBDCommand import OBDCommand
33-
from decoders import *
34-
from debug import debug
32+
from .OBDCommand import OBDCommand
33+
from .decoders import *
34+
from .debug import debug
3535

3636

3737

@@ -203,7 +203,7 @@ def __init__(self):
203203
def __getitem__(self, key):
204204
if isinstance(key, int):
205205
return self.modes[key]
206-
elif isinstance(key, basestring):
206+
elif isinstance(key, str):
207207
return self.__dict__[key]
208208
else:
209209
debug("OBD commands can only be retrieved by PID value or dict name", True)
@@ -250,7 +250,7 @@ def has_command(self, c):
250250

251251
# checks for existance of command by name
252252
def has_name(self, s):
253-
if isinstance(s, basestring):
253+
if isinstance(s, str):
254254
return s.isupper() and (s in self.__dict__.keys())
255255
else:
256256
debug("has_name() only accepts string names for commands", True)

obd/decoders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
########################################################################
3131

3232
import math
33-
from utils import *
34-
from codes import *
35-
from debug import debug
33+
from .utils import *
34+
from .codes import *
35+
from .debug import debug
3636

3737
'''
3838
All decoders take the form:

obd/elm327.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232
import serial
3333
import time
34-
from protocols import *
35-
from utils import strip, numBitsSet
36-
from debug import debug
34+
from .protocols import *
35+
from .utils import strip, numBitsSet
36+
from .debug import debug
3737

3838

3939

obd/obd.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@
3030
########################################################################
3131

3232
import time
33-
from elm327 import ELM327
34-
from commands import commands
35-
from utils import scanSerial, Response
36-
from debug import debug
33+
from .elm327 import ELM327
34+
from .commands import commands
35+
from .utils import scanSerial, Response
36+
from .debug import debug
37+
from .port import OBDPort, State
38+
from .commands import commands
39+
from .utils import scanSerial, Response
40+
from .debug import debug
3741

3842

3943

@@ -139,7 +143,7 @@ def load_commands(self):
139143

140144
def print_commands(self):
141145
for c in self.supported_commands:
142-
print str(c)
146+
print(str(c))
143147

144148

145149
def supports(self, c):

obd/protocols/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
# #
3030
########################################################################
3131

32-
from protocol_legacy import SAE_J1850_PWM, \
32+
from .protocol_legacy import SAE_J1850_PWM, \
3333
SAE_J1850_VPW, \
3434
ISO_9141_2, \
3535
ISO_14230_4_5baud, \
3636
ISO_14230_4_fast
3737

38-
from protocol_can import ISO_15765_4_11bit_500k, \
38+
from .protocol_can import ISO_15765_4_11bit_500k, \
3939
ISO_15765_4_29bit_500k, \
4040
ISO_15765_4_11bit_250k, \
4141
ISO_15765_4_29bit_250k, \

obd/protocols/protocol_can.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# #
3030
########################################################################
3131

32-
from protocol import *
32+
from .protocol import *
3333

3434

3535
class CANProtocol(Protocol):

obd/protocols/protocol_legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# #
3030
########################################################################
3131

32-
from protocol import *
32+
from .protocol import *
3333

3434

3535
class LegacyProtocol(Protocol):

0 commit comments

Comments
 (0)