#NEWLINE# def update( self , resource , debug = False ) : #NEWLINE# #INDENT# "\n        @summary: Rename lights, or set a light's state, as determined by the                  resource object.\n        " #NEWLINE# request = Request ( ) #NEWLINE# if resource [ 'data' ] . has_key ( 'attr' ) : #NEWLINE# #INDENT# service = 'lights/{id}' . format ( id = resource [ 'which' ] ) #NEWLINE# data = resource [ 'data' ] [ 'attr' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if resource [ 'data' ] . has_key ( 'state' ) : #NEWLINE# #INDENT# service = 'lights/{id}/state' . format ( id = status [ 'which' ] ) #NEWLINE# data = resource [ 'data' ] [ 'state' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Unknown data type.' ) #NEWLINE# #UNINDENT# #UNINDENT# path = 'api/{username}/{service}' . format ( username = self . user [ 'name' ] , service = service ) #NEWLINE# url = 'http://{bridge_ip}/{path}' . format ( bridge_ip = self . bridge [ 'ip' ] , path = path ) #NEWLINE# ( status , content ) = request . put ( url , data ) #NEWLINE# if debug : #NEWLINE# #INDENT# return dict ( info = status , resource = content ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return dict ( resource = content )