'Handle any <include file="foo"> tags by reading in the specified file and inserting it
into our XML tree.  Fail gracefully if debugging.'

def _process_includes(self):

    includes = self.tree.findall('.//include')
    for inc in includes:
        filename = inc.get('file')
        if (filename is not None):
            try:
                ifp = self.capa_system.filestore.open(filename)
            except Exception as err:
                log.warning('Error    %s    in    problem    xml    include:    %s', err, etree.tostring(inc, pretty_print=True))
                log.warning('Cannot    find    file    %s    in    %s', filename, self.capa_system.filestore)
                if (not self.capa_system.DEBUG):
                    raise
                else:
                    continue
            try:
                incxml = etree.XML(ifp.read())
            except Exception as err:
                log.warning('Error    %s    in    problem    xml    include:    %s', err, etree.tostring(inc, pretty_print=True))
                log.warning('Cannot    parse    XML    in    %s', filename)
                if (not self.capa_system.DEBUG):
                    raise
                else:
                    continue
            parent = inc.getparent()
            parent.insert(parent.index(inc), incxml)
            parent.remove(inc)
            log.debug('Included    %s    into    %s', filename, self.problem_id)
