Go to the documentation of this file.00001 import pickle
00002 from Phidgets.Devices.IR import IR, IRCode, IRCodeInfo
00003
00004 def filterObject(obj):
00005 attrs = [e for e in dir(obj) if not e.startswith('_')]
00006 return dict(zip(attrs, [getattr(obj, e) for e in attrs]))
00007
00008 def saveIRCode(filename, code, code_info):
00009 c_dict = filterObject(code)
00010 del c_dict['toString']
00011 with open(filename, 'w') as f:
00012 pickle.dump({'code': c_dict, 'code_info': code_info.toCPhidgetIR_CodeInfo()}, f)
00013
00014 def loadIRCode(filename):
00015 with open(filename, 'r') as f:
00016 data = pickle.load(f)
00017 code = IRCode(data['code']['Data'], data['code']['BitCount'])
00018 code_info = IRCodeInfo(data['code_info'])
00019 return code, code_info