#NEWLINE# def _classOrFunctionDefinition( self , pyObject , classOrFunction ) : #NEWLINE# #INDENT# '\n        `_classOrFunctionDefinition: create a `_FunctionDefinition` or\n        `_ClassDefinition` out of a python class or function, recursively visiting\n        the resolvable free variable member access chains in `pyObject` as well\n        as the source file object.\n\n        Args:\n            `pyObject`: a python class or function.\n            `classOrFunction`: should either be `_FunctionDefinition` or\n                `_ClassDefinition`.\n\n        Returns:\n            a `_FunctionDefinition` or `_ClassDefinition`.\n\n        ' #NEWLINE# if ( pyObject . __name__ == '__inline_fora' ) : #NEWLINE# #INDENT# raise Exceptions . PythonToForaConversionError ( "in pyfora, '__inline_fora' is a reserved word" ) #NEWLINE# #UNINDENT# ( sourceFileText , sourceFileName ) = PyAstUtil . getSourceFilenameAndText ( pyObject ) #NEWLINE# ( _ , sourceLine ) = PyAstUtil . getSourceLines ( pyObject ) #NEWLINE# sourceAst = PyAstUtil . pyAstFromText ( sourceFileText ) #NEWLINE# if ( classOrFunction is _FunctionDefinition ) : #NEWLINE# #INDENT# pyAst = PyAstUtil . functionDefOrLambdaAtLineNumber ( sourceAst , sourceLine ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert ( classOrFunction is _ClassDefinition ) #NEWLINE# pyAst = PyAstUtil . classDefAtLineNumber ( sourceAst , sourceLine ) #NEWLINE# #UNINDENT# assert ( sourceLine == pyAst . lineno ) #NEWLINE# try : #NEWLINE# #INDENT# freeVariableMemberAccessChainResolutions = self . _computeAndResolveFreeVariableMemberAccessChainsInAst ( pyObject , pyAst ) #NEWLINE# #UNINDENT# except UnresolvedFreeVariableException as e : #NEWLINE# #INDENT# _convertUnresolvedFreeVariableExceptionAndRaise ( freeVariableMemberAccessChainResolutions , sourceFileName ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# processedFreeVariableMemberAccessChainResolutions = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( chain , ( resolution , location ) ) in freeVariableMemberAccessChainResolutions . iteritems ( ) : #NEWLINE# #INDENT# processedFreeVariableMemberAccessChainResolutions [ '.' . join ( chain ) ] = self . walkPyObject ( resolution ) #NEWLINE# #UNINDENT# #UNINDENT# except UnresolvedFreeVariableExceptionWithTrace as e : #NEWLINE# #INDENT# e . addToTrace ( Exceptions . makeTraceElement ( path = sourceFileName , lineNumber = location [ 0 ] ) ) #NEWLINE# raise #NEWLINE# #UNINDENT# sourceFileId = self . walkPyObject ( _FileDescription . cachedFromArgs ( fileName = sourceFileName , fileText = sourceFileText ) ) #NEWLINE# return classOrFunction ( sourceFileId = sourceFileId , lineNumber = sourceLine , freeVariableMemberAccessChainsToId = processedFreeVariableMemberAccessChainResolutions )