pcdshub / device_config

Happi device configuration for PCDS devices
https://github.com/pcdshub/device_config/blob/master/db.json
Other
0 stars 11 forks source link

MNT: Change device IDs from prefixes to names #14

Closed ZryletTC closed 4 years ago

ZryletTC commented 4 years ago

Standardizes the device IDs match an entry's name as they were mixed between using prefixes and names in the past.

Code that I ran (minus syntax errors and random prints I wanted to check):

In [1]: import json                                                                                     

In [4]: with open('db.json') as infile: 
   ...:     db = json.load(infile) 
   ...:                                                                                                 

In [6]: newdb = {}                                                                                      

In [10]: for key in db: 
    ...:     db[key]['_id'] = db[key]['name'] 
    ...:                                                                                                

In [11]: for key in db: 
    ...:     newdb[db[key]['name']] = db[key] 
    ...:                                                                                                

In [15]: with open('db.json','w') as outfile: 
    ...:     json.dump(newdb, outfile) 
klauer commented 4 years ago

Just need to do a pull in device_config now.