@@ -201,6 +201,14 @@ def __init__(self):
201201
202202
203203 def __getitem__ (self , key ):
204+ """
205+ commands can be accessed by name, or by mode/pid
206+
207+ obd.commands.RPM
208+ obd.commands["RPM"]
209+ obd.commands[1][12] # mode 1, PID 12 (RPM)
210+ """
211+
204212 if isinstance (key , int ):
205213 return self .modes [key ]
206214 elif isinstance (key , str ) or isinstance (key , unicode ):
@@ -210,18 +218,20 @@ def __getitem__(self, key):
210218
211219
212220 def __len__ (self ):
221+ """ returns the number of commands supported by python-OBD """
213222 l = 0
214223 for m in self .modes :
215224 l += len (m )
216225 return l
217226
218227
219228 def __contains__ (self , s ):
229+ """ calls has_name(s) """
220230 return self .has_name (s )
221231
222232
223- # returns a list of PID GET commands
224233 def pid_getters (self ):
234+ """ returns a list of PID GET commands """
225235 getters = []
226236 for m in self .modes :
227237 for c in m :
@@ -230,35 +240,35 @@ def pid_getters(self):
230240 return getters
231241
232242
233- # sets the boolean supported flag for the given command
234243 def set_supported (self , mode , pid , v ):
244+ """ sets the boolean supported flag for the given command """
235245 if isinstance (v , bool ):
236246 if self .has (mode , pid ):
237247 self .modes [mode ][pid ].supported = v
238248 else :
239249 debug ("set_supported() only accepts boolean values" , True )
240250
241251
242- # checks for existance of command by OBDCommand object
243252 def has_command (self , c ):
253+ """ checks for existance of a command by OBDCommand object """
244254 if isinstance (c , OBDCommand ):
245255 return c in self .__dict__ .values ()
246256 else :
247257 debug ("has_command() only accepts OBDCommand objects" , True )
248258 return False
249259
250260
251- # checks for existance of command by name
252261 def has_name (self , s ):
262+ """ checks for existance of a command by name """
253263 if isinstance (s , str ) or isinstance (s , unicode ):
254264 return s .isupper () and (s in self .__dict__ .keys ())
255265 else :
256266 debug ("has_name() only accepts string names for commands" , True )
257267 return False
258268
259269
260- # checks for existance of int mode and int pid
261270 def has_pid (self , mode , pid ):
271+ """ checks for existance of a command by int mode and int pid """
262272 if isinstance (mode , int ) and isinstance (pid , int ):
263273 if (mode < 0 ) or (pid < 0 ):
264274 return False
0 commit comments