(self, id, src)
Add an instance with an id and src if it doesn't exist already
        If the id already exists, DOES NOT overwrite.
Add an instance with an id and src if it doesn't exist already
        If the id already exists, DOES NOT overwrite.
Add an instance with an id and src if it doesn t exist already If the id already exists DOES NOT overwrite .
def add_instance(self, id, src):
        """
        Add an instance with an id and src if it doesn't exist already
        If the id already exists, DOES NOT overwrite.

        """
        instance_xpath = 'instance[@id="%s"]' % id
        conflicting = (
            self.model_node.find('{f}%s' % instance_xpath).exists() or
            self.model_node.find(instance_xpath).exists()
        )
        if not conflicting:
            # insert right after the main <instance> block
            first_instance = self.model_node.find('{f}instance')
            first_instance.addnext(_make_elem('instance', {'id': id, 'src': src}))
def add_instance ( self , id , src ) : instance_xpath = 'instance[@id="%s"]' % id conflicting = ( self . model_node . find ( '{f}%s' % instance_xpath ) . exists ( ) or self . model_node . find ( instance_xpath ) . exists ( ) ) if not conflicting : # insert right after the main <instance> block first_instance = self . model_node . find ( '{f}instance' ) first_instance . addnext ( _make_elem ( 'instance' , { 'id' : id , 'src' : src } ) )