#NEWLINE# def _create_instance( self , cls , args , ref = None ) : #NEWLINE# #INDENT# "\n        Returns an instance of `cls` with `args` passed as arguments.\n\n        Recursively inspects `args` to create nested objects and functions as\n        necessary.\n\n        `cls` will only be considered only if it's an object we track\n         (i.e.: troposphere objects).\n\n        If `cls` has a `props` attribute, nested properties will be\n         instanciated as troposphere Property objects as necessary.\n\n        If `cls` is a list and contains a single troposphere type, the\n         returned value will be a list of instances of that type.\n        " #NEWLINE# if isinstance ( cls , Sequence ) : #NEWLINE# #INDENT# if ( len ( cls ) == 1 ) : #NEWLINE# #INDENT# if ( isinstance ( args , basestring ) or ( not isinstance ( args , Sequence ) ) ) : #NEWLINE# #INDENT# args = [ args ] #NEWLINE# #UNINDENT# return [ self . _create_instance ( cls [ 0 ] , v ) for v in args ] #NEWLINE# #UNINDENT# #UNINDENT# if ( isinstance ( cls , Sequence ) or ( cls not in self . inspect_members ) ) : #NEWLINE# #INDENT# return self . _convert_definition ( args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if issubclass ( cls , AWSHelperFn ) : #NEWLINE# #INDENT# if ( isinstance ( args , Sequence ) and ( not isinstance ( v , basestring ) ) ) : #NEWLINE# #INDENT# return cls ( * self . _convert_definition ( args ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if issubclass ( cls , autoscaling . Metadata ) : #NEWLINE# #INDENT# return self . _generate_autoscaling_metadata ( cls , args ) #NEWLINE# #UNINDENT# args = self . _convert_definition ( args ) #NEWLINE# if ( isinstance ( args , Ref ) and issubclass ( cls , Ref ) ) : #NEWLINE# #INDENT# return args #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return cls ( args ) #NEWLINE# #UNINDENT# except TypeError as ex : #NEWLINE# #INDENT# if ( '__init__() takes exactly' not in ex . message ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# return GenericHelperFn ( args ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( args , Mapping ) : #NEWLINE# #INDENT# kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# kwargs . update ( args ) #NEWLINE# for prop_name in getattr ( cls , 'props' , [ ] ) : #NEWLINE# #INDENT# if ( prop_name not in kwargs ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# expected_type = cls . props [ prop_name ] [ 0 ] #NEWLINE# if ( isinstance ( expected_type , Sequence ) or ( expected_type in self . inspect_members ) ) : #NEWLINE# #INDENT# kwargs [ prop_name ] = self . _create_instance ( expected_type , kwargs [ prop_name ] , prop_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kwargs [ prop_name ] = self . _convert_definition ( kwargs [ prop_name ] , prop_name ) #NEWLINE# #UNINDENT# #UNINDENT# args = self . _convert_definition ( kwargs ) #NEWLINE# if isinstance ( args , Ref ) : #NEWLINE# #INDENT# return args #NEWLINE# #UNINDENT# assert isinstance ( args , Mapping ) #NEWLINE# return cls ( title = ref , ** args ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return cls ( self . _convert_definition ( args ) )