<commit_before>"""
Module containing the Dom class.
"""

from utils import correct_type
from tag import Tag


class Dom(object):
    """
    Document Object Model class. Contains root of the HTML tag tree.
    """

    def __init__(self, root=None):
        """
        Initializer. Sets the root atrribute.
        :param root: Root Tag of the HTML tag tree. Usually the <html> element.
        :return: None
        """
        self.root = root
        if self.root is not None:
            correct_type(root, Tag)

    def get_tags(self, root, tags=None, recursive=True):
        """
        Gets all child tags from a Tag object.
        :param root: Tag object, from where children are searched.
        :param tags: tags list where found children are added
        :param recursive: boolean determining whether the search is recursive
        :return: list of tags
        """
        if tags is None:
            tags = []
        for child in root.children:
            tags.append(child)
            print "got here"
            print len(tags)
            if recursive:
                self.get_tags(child, tags)
        return tags<commit_msg>(Cleanliness) Made recursion nicer and reformatted print statements<commit_after>"""
Module containing the Dom class.
"""

from utils import correct_type
from tag import Tag


class Dom(object):
    """
    Document Object Model class. Contains root of the HTML tag tree.
    """

    def __init__(self, root=None):
        """
        Initializer. Sets the root atrribute.
        :param root: Root Tag of the HTML tag tree. Usually the <html> element.
        :return: None
        """
        self.root = root
        if self.root is not None:
            correct_type(root, Tag)

    def get_tags(self, root, recursive=True):
        """
        Gets all child tags from a Tag object.
        :param root: Tag object, from where children are searched.
        :param recursive: boolean determining whether the search is recursive
        :return: list of tags
        """
        tags = []
        for child in root.children:
            tags.append(child)
            print("got here")
            print(len(tags))
            if recursive:
                tags += self.get_tags(child)
        return tags
{'fraction_non_alphanumeric': 0.08215547703180212, 'fraction_numerical': 0.0, 'mean_word_length': 1.9607843137254901, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '304805', 'n_tokens_mistral': 591, 'n_tokens_neox': 577, 'n_words': 238}