#NEWLINE# def register_hal( uri = 'http://www.example.com/' , links = None , state = None , title = None , method = 'GET' , headers = None , status = 200 ) : #NEWLINE# #INDENT# 'Convenience function that registers a hal document at a given address' #NEWLINE# def body_callback( _meth , req_uri , req_headers ) : #NEWLINE# #INDENT# 'This is either registered for dynamic uris or is called for a\n        static uri' #NEWLINE# _links = ( links . copy ( ) if ( links is not None ) else { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# _state = ( state . copy ( ) if ( state is not None ) else { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( headers is not None ) : #NEWLINE# #INDENT# resp_headers = headers . copy ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# resp_headers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( req_headers is not None ) : #NEWLINE# #INDENT# resp_headers . update ( req_headers ) #NEWLINE# #UNINDENT# resp_headers . update ( { #NEWLINE# #INDENT# 'server' : 'HTTPretty 0.6.0' , #NEWLINE# #UNINDENT# } ) #NEWLINE# _links . update ( { #NEWLINE# #INDENT# 'self' : { #NEWLINE# #INDENT# 'href' : req_uri , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( title is not None ) : #NEWLINE# #INDENT# _links [ 'self' ] [ 'title' ] = title #NEWLINE# #UNINDENT# _state . update ( { #NEWLINE# #INDENT# '_links' : _links , #NEWLINE# #UNINDENT# } ) #NEWLINE# return ( status , resp_headers , json . dumps ( _state ) ) #NEWLINE# #UNINDENT# httpretty . HTTPretty . register_uri ( method = method , body = body_callback , content_type = 'application/hal+json' , uri = uri )