<commit_before>
class Porter:

    def __init__(self):
        self.indent = '    '

    def port(self, path):
        # Result:
        out = []

        # Load data:
        with open(path, 'r') as file:
            content = file.readlines()

        # Remove whitespace:
        for line in content:
            line = line.strip()
            # action!

        return ''.join(out)<commit_msg>add basic tree traversal<commit_after>

class Node:

    def __init__(self, start, end, depth=0):
        self.start = start
        self.scope = []
        self.end = end
        self.depth = depth

    def __str__(self):
        content = '\n'.join([str(node) for node in self.scope])
        return '\n'.join([self.start, content, self.end])


class Porter:

    def __init__(self):
        self.indent = '    '

    def port(self, path):

        # Load data:
        with open(path, 'r') as file:
            content = file.readlines()

        # Parse data:
        tree = Node('', '')
        for line in content:
            line = line.strip()

            depth = line.count('|   ')
            retrn = line.count(':') == 1
            condition = line[(depth * len(self.indent)):]

            # Get current node:
            node = None
            if depth > 0:
                while depth > 0:
                    if node is None:
                        node = tree.scope[-1]
                    else:
                        node = node.scope[-1]
                    depth = depth - 1
            else:
                node = tree.scope

            new = Node('if (' + condition + ') {', '}')
            if retrn:
                new.scope.append('return somewhat')
                if type(node) is list:
                    node.append(new)
                else:
                    node.scope.append(new)
            else:
                if depth > 0:
                    node.scope.append(new)
                else:
                    if type(node) is list:
                        node.append(new)
                    else:
                        node.scope.append(new)

            # if depth <= prev_depth:
            #     out.append(depth * self.indent + '}')

            # out.append(depth * self.indent + 'if (' + condition + ') {')
            # if retrn:
            #     out.append((depth + 1) * self.indent + 'return somewhat;')
            #     out.append((depth) * self.indent + '}')
            # else:
            #     prev_depth = depth

            # print(condition)
            # print(booom)


            #
            # indents = line.count('|   ') * self.indent
            # print()
            # print('original:')
            # print(line)
            # print('output:')
            # condition = line[len(indents):]

        return str(tree)
{'fraction_non_alphanumeric': 0.12200357781753131, 'fraction_numerical': 0.0032200357781753132, 'mean_word_length': 1.134351145038168, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '3789422', 'n_tokens_mistral': 786, 'n_tokens_neox': 736, 'n_words': 182}