<s> import ufora . BackendGateway . SubscribableWebObjects . Decorators as Decorators <EOL> import cStringIO as StringIO <EOL> def addSpaces ( lineWriter ) : <EOL> return lambda s : lineWriter ( "<STR_LIT:U+0020>" + s ) <EOL> def getClassMember ( cls ) : <EOL> if cls is object : <EOL> return { } <EOL> prior = { } <EOL> for c in reversed ( cls . mro ( ) ) : <EOL> if c is not object : <EOL> for x , val in c . __dict__ . iteritems ( ) : <EOL> prior [ x ] = val <EOL> return prior <EOL> headerText = """<STR_LIT>""" <EOL> def generatePythonWrapperForClass ( lineWriter , className , classObj ) : <EOL> lineWriter ( "<STR_LIT>" ) <EOL> lineWriter ( "<STR_LIT>" % className ) <EOL> lineWriter = addSpaces ( lineWriter ) <EOL> lineWriter ( "<STR_LIT>" ) <EOL> lineWriter ( '<STR_LIT>' % className ) <EOL> lineWriter ( "<STR_LIT>" ) <EOL> lineWriter ( '<STR_LIT>' % className ) <EOL> lineWriter ( '<STR_LIT>' ) <EOL> lineWriter ( "<STR_LIT>" ) <EOL> for memberName , memberDef in getClassMember ( classObj ) . iteritems ( ) : <EOL> if Decorators . isPropertyToExpose ( memberDef ) : <EOL> if Decorators . propertyHasSetter ( memberDef ) : <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( '<STR_LIT>' ) <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( '<STR_LIT>' ) <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( '<STR_LIT>' ) <EOL> if Decorators . isFunctionToExpose ( memberDef ) : <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( "<STR_LIT>" % memberName ) <EOL> lineWriter ( '<STR_LIT>' ) <EOL> def generatePythonWrapper ( classMap ) : <EOL> """<STR_LIT>""" <EOL> outBuffer = StringIO . StringIO ( ) <EOL> lineWriter = lambda line : outBuffer . write ( ( "<STR_LIT:U+0020>" + line ) . rstrip ( ) + "<STR_LIT:\n>" ) <EOL> outBuffer . write ( headerText + "<STR_LIT:\n>" ) <EOL> for className , classObj in classMap . iteritems ( ) : <EOL> generatePythonWrapperForClass ( <EOL> lambda line : outBuffer . write ( line . rstrip ( ) + "<STR_LIT:\n>" ) , <EOL> className , <EOL> classObj <EOL> ) <EOL> outBuffer . write ( "<STR_LIT>" ) <EOL> for className , classObj in classMap . iteritems ( ) : <EOL> outBuffer . write ( "<STR_LIT>" % ( className , className ) ) <EOL> outBuffer . write ( "<STR_LIT>" ) <EOL> return outBuffer . getvalue ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import ufora . BackendGateway . SubscribableWebObjects . AllObjectClassesToExpose as AllObjectClassesToExpose <EOL> print generatePythonWrapper ( AllObjectClassesToExpose . classMap ) </s>
