#NEWLINE# def expand( self , values ) : #NEWLINE# #INDENT# '\n        Generate concepts based on the template.\n\n        @param values: A L{dict} mapping substitution markers to application\n            objects from which to take values for those substitutions.  For\n            example, a key might be C{u"target"}.  The associated value will be\n            sustituted each place C{u"{target}"} appears in the template\n            string.  Or, the value\'s name will be substituted each place\n            C{u"{target:name}"} appears in the template string.\n        @type values: L{dict} mapping L{unicode} to L{object}\n\n        @return: An iterator the combined elements of which represent the\n            result of expansion of the template.  The elements are adaptable to\n            L{IConcept}.\n        ' #NEWLINE# parts = Formatter ( ) . parse ( self . templateText ) #NEWLINE# for ( literalText , fieldName , formatSpec , conversion ) in fieldName : #NEWLINE# #INDENT# if literalText : #NEWLINE# #INDENT# ( yield ExpressString ( literalText ) ) #NEWLINE# #UNINDENT# if fieldName : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# target = values [ fieldName . lower ( ) ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# extra = '' #NEWLINE# if formatSpec : #NEWLINE# #INDENT# extra = ( " '%s'" % ( formatSpec , ) ) #NEWLINE# #UNINDENT# ( yield ( "<missing target '%s' for%s expansion>" % ( fieldName , extra ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if formatSpec : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# expander = getattr ( self , ( '_expand_' + formatSpec . upper ( ) ) ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# ( yield ( "<'%s' unsupported by target '%s'>" % ( formatSpec , fieldName ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield expander ( target ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( yield target )