#NEWLINE# def resolve( self , jref , parser = None ) : #NEWLINE# #INDENT# ' JSON reference resolver\n\n        :param str jref: a JSON Reference, refer to http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03 for details.\n        :param parser: the parser corresponding to target object.\n        :type parser: pyswagger.base.Context\n        :return: the referenced object, wrapped by weakref.ProxyType\n        :rtype: weakref.ProxyType\n        :raises ValueError: if path is not valid\n        ' #NEWLINE# logger . info ( 'resolving: [{0}]' . format ( jref ) ) #NEWLINE# if ( ( jref == None ) or ( len ( jref ) == 0 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Empty Path is not allowed' ) #NEWLINE# #UNINDENT# obj = None #NEWLINE# ( url , jp ) = utils . jr_split ( jref ) #NEWLINE# if url : #NEWLINE# #INDENT# o = self . __objs . get ( url , None ) #NEWLINE# if o : #NEWLINE# #INDENT# if isinstance ( jref , BaseObj ) : #NEWLINE# #INDENT# obj = o . resolve ( utils . jp_split ( jp ) [ 1 : ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( o , dict ) : #NEWLINE# #INDENT# for ( k , v ) in six . iteritems ( o ) : #NEWLINE# #INDENT# if jp . startswith ( k ) : #NEWLINE# #INDENT# obj = v . resolve ( utils . jp_split ( jp [ len ( k ) : ] ) [ 1 : ] ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( 'Unknown Cached Object: {0}' . format ( str ( type ( o ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( obj == None ) : #NEWLINE# #INDENT# ( obj , _ ) = self . load_obj ( jref , parser = parser ) #NEWLINE# if obj : #NEWLINE# #INDENT# obj = self . prepare_obj ( obj , jref ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not jp . startswith ( '#' ) ) : #NEWLINE# #INDENT# raise ValueError ( "Invalid Path, root element should be '#', but [{0}]" . format ( jref ) ) #NEWLINE# #UNINDENT# obj = self . root . resolve ( utils . jp_split ( jp ) [ 1 : ] ) #NEWLINE# #UNINDENT# if ( obj == None ) : #NEWLINE# #INDENT# raise ValueError ( 'Unable to resolve path, [{0}]' . format ( jref ) ) #NEWLINE# #UNINDENT# if isinstance ( obj , ( six . string_types , six . integer_types , list , dict ) ) : #NEWLINE# #INDENT# return obj #NEWLINE# #UNINDENT# return weakref . proxy ( obj )