<commit_before>import xml.dom.minidom


class Entry(object):
    def __init__(self, entryNode):
        if isinstance(entryNode, basestring):
            entryNode = xml.dom.minidom.parseString(entryNode)
            if not entryNode:
                raise Exception("Error constructing feed Domdoc")

        self.title = entryNode.getElementsByTagName('title').item(0).childNodes.item(0).nodeValue
        self.id = entryNode.getElementsByTagName('id').item(0).childNodes.item(0).nodeValue
        self.dateAdded = entryNode.getElementsByTagName('published').item(0).childNodes.item(0).nodeValue
        self.dateUpdated = entryNode.getElementsByTagName('updated').item(0).childNodes.item(0).nodeValue
        self.links = {}
        for n in entryNode.childNodes:
            if n.nodeName == 'link':
                linkrel = n.getAttribute('rel')
                linktype = n.getAttribute('type')
                linkhref = n.getAttribute('href')
                self.links[linkrel] = {'type': linktype, 'href': linkhref, 'rel': linkrel}
                if linkrel == 'enclosure':
                    self.links[linkrel]['title'] = n.getAttribute('title')
                    self.links[linkrel]['size'] = n.getAttribute('size')

        contentNode = entryNode.getElementsByTagName("content").item(0)
        self.contentType = contentNode.getAttribute('type')
        self.contentZType = contentNode.getAttribute('zapi:type')<commit_msg>only grab content attributes if content node exists<commit_after>import logging
import xml.dom.minidom


class Entry(object):
    def __init__(self, entryNode):
        if isinstance(entryNode, basestring):
            logging.info("doc is a string. make it a dom")
            entryNode = xml.dom.minidom.parseString(entryNode)
            if not entryNode:
                raise Exception("Error constructing feed Domdoc")

        self.title = entryNode.getElementsByTagName('title').item(0).childNodes.item(0).nodeValue
        self.id = entryNode.getElementsByTagName('id').item(0).childNodes.item(0).nodeValue
        self.dateAdded = entryNode.getElementsByTagName('published').item(0).childNodes.item(0).nodeValue
        self.dateUpdated = entryNode.getElementsByTagName('updated').item(0).childNodes.item(0).nodeValue
        self.links = {}
        for n in entryNode.childNodes:
            if n.nodeName == 'link':
                linkrel = n.getAttribute('rel')
                linktype = n.getAttribute('type')
                linkhref = n.getAttribute('href')
                self.links[linkrel] = {'type': linktype, 'href': linkhref, 'rel': linkrel}
                if linkrel == 'enclosure':
                    self.links[linkrel]['title'] = n.getAttribute('title')
                    self.links[linkrel]['size'] = n.getAttribute('size')

        contentNode = entryNode.getElementsByTagName("content").item(0)
        if(contentNode):
            self.contentType = contentNode.getAttribute('type')
            self.contentZType = contentNode.getAttribute('zapi:type')
{'fraction_non_alphanumeric': 0.12759643916913946, 'fraction_numerical': 0.005934718100890208, 'mean_word_length': 2.7045177045177047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1035111', 'n_tokens_mistral': 844, 'n_tokens_neox': 833, 'n_words': 141}