def _parse_classad(c):
    """Turn a ClassAd XML fragment into a dictionary of Python values.

    Note that this supports only the small subset of the ClassAd XML
    syntax [2]_ that we need to determine if a job succeeded or failed.
    """
    if c is not None:
        for a in c.findall('a'):
            key = a.attrib['n']
            child, = a.getchildren()
            if child.tag == 's':
                value = str(child.text)
            elif child.tag == 'b':
                value = child.attrib['v'] == 't'
            elif child.tag == 'i':
                value = int(child.text)
            else:
                continue
            yield key, value
