265
265
u'FFFF' : u'K20 BOOTLOADER' ,
266
266
u'RIOT' : u'RIOT' ,
267
267
},
268
- 'jlink' : {
269
- u'X349858SLYN' : u'NRF52_DK' ,
270
- u'FRDM-KL25Z' : u'KL25Z' ,
271
- u'FRDM-KL27Z' : u'KL27Z' ,
272
- u'FRDM-KL43Z' : u'KL43Z'
268
+ u'jlink' : {
269
+ u'X349858SLYN' : {
270
+ u'platform_name' : u'NRF52_DK' ,
271
+ u'jlink_device_name' : u'nRF52832_xxaa'
272
+ },
273
+ u'FRDM-KL25Z' : {
274
+ u'platform_name' : u'KL25Z' ,
275
+ u'jlink_device_name' : u'MKL25Z128xxx4'
276
+ },
277
+ u'FRDM-KL27Z' : {
278
+ u'platform_name' : u'KL27Z' ,
279
+ u'jlink_device_name' : u'MKL27Z64xxx4'
280
+ },
281
+ u'FRDM-KL43Z' : {
282
+ u'platform_name' : u'KL43Z' ,
283
+ u'jlink_device_name' : u'MKL43Z256xxx4'
284
+ }
273
285
}
274
286
}
275
287
@@ -286,6 +298,21 @@ def _older_than_me(path):
286
298
return _get_modified_time (path ) < _get_modified_time (__file__ )
287
299
288
300
301
+ def _modify_data_format (data , verbose_data , simple_data_key = 'platform_name' ):
302
+ if isinstance (data , dict ):
303
+ if verbose_data :
304
+ return data
305
+
306
+ return data [simple_data_key ]
307
+ else :
308
+ if verbose_data :
309
+ return {
310
+ simple_data_key : data
311
+ }
312
+
313
+ return data
314
+
315
+
289
316
def _overwrite_or_open (db ):
290
317
try :
291
318
if db is LOCAL_PLATFORM_DATABASE and _older_than_me (db ):
@@ -357,13 +384,14 @@ def items(self, device_type='daplink'):
357
384
def all_ids (self , device_type = 'daplink' ):
358
385
return iter (self ._keys [device_type ])
359
386
360
- def get (self , index , default = None , device_type = 'daplink' ):
361
- """Standard lookup function. Works exactly like a dict"""
387
+ def get (self , index , default = None , device_type = 'daplink' , verbose_data = False ):
388
+ """Standard lookup function. Works exactly like a dict. If 'verbose_data'
389
+ is True, all data for the platform is returned as a dict."""
362
390
for db in self ._dbs .values ():
363
391
if device_type in db :
364
392
maybe_answer = db [device_type ].get (index , None )
365
393
if maybe_answer :
366
- return maybe_answer
394
+ return _modify_data_format ( maybe_answer , verbose_data )
367
395
368
396
return default
369
397
@@ -411,9 +439,10 @@ def add(self, id, platform_name, permanent=False, device_type='daplink'):
411
439
else :
412
440
raise ValueError ("Invald target id: %s" % id )
413
441
414
- def remove (self , id , permanent = False , device_type = 'daplink' ):
442
+ def remove (self , id , permanent = False , device_type = 'daplink' , verbose_data = False ):
415
443
"""Remove a platform from this database, optionally updating an origin
416
- database
444
+ database. If 'verbose_data' is True, all data for the platform is returned
445
+ as a dict.
417
446
"""
418
447
logger .debug ("Trying remove of %s" , id )
419
448
if id is '*' and device_type in self ._dbs [self ._prim_db ]:
@@ -426,4 +455,5 @@ def remove(self, id, permanent=False, device_type='daplink'):
426
455
self ._keys [device_type ].remove (id )
427
456
if permanent :
428
457
self ._update_db ()
429
- return removed
458
+
459
+ return _modify_data_format (removed , verbose_data )
0 commit comments