#NEWLINE# def _ensure_only_component_references( cmd , references ) : #NEWLINE# #INDENT# ' Search through tag references in a command, ensure that\n    they all reference ComponentIDs\n\n    Parameters\n    ----------\n    cmd : string. A template command\n    referenes : a mapping from tags to substitution objects\n\n    Raises\n    ------\n    TypeError, if cmd does not refer only to ComponentIDs\n    ' #NEWLINE# for match in TAG_RE . finditer ( cmd ) : #NEWLINE# #INDENT# tag = match . group ( 'tag' ) #NEWLINE# if ( ( tag not in references ) or ( not isinstance ( references [ tag ] , ComponentID ) ) ) : #NEWLINE# #INDENT# raise TypeError ( ( 'Reference to %s, which is not a ComponentID' % tag ) )