<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json


# TODO: Do we want to directories here?
class Manifest(object):
    """
    A Manifest describes a set of files along with their hashes
    """
    def __init__(self):
        # List of hash, filename, permission tuples
        self.files = []

    def add(self, h, filename, perms):
        """
        Adds a file to the manifest

        Arguments:
            h (str): the sha1 has of the file
            filename (str): the filename, usually relative to some top level directory
            perms (int): integer representation of file permissions
        """
        self.files.append((h, filename, perms))

    def save(self, output_file):
        """
        Outputs the manifest to a file object. Permissions are output in octal representation.

        Arguments:
            output_file (file object): the file object to write the manifest to
        """
        data = json.dumps(self.files, output_file, indent=2)
        data = data.encode("utf8")
        output_file.write(data)

        #for h, filename, perms in self.files:<commit_msg>update docs<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json


# TODO: Do we want to handle directories here?
class Manifest(object):
    """
    A Manifest describes a set of files along with their hashes and permissions
    """
    def __init__(self):
        # List of hash, filename, permission tuples
        self.files = []

    def add(self, h, filename, perms):
        """
        Adds a file to the manifest

        Arguments:
            h (str): the sha1 has of the file
            filename (str): the filename, usually relative to some top level directory
            perms (int): integer representation of file permissions
        """
        self.files.append((h, filename, perms))

    def save(self, output_file):
        """
        Outputs the manifest to a file object. Permissions are output in octal representation.

        Arguments:
            output_file (file object): the file object to write the manifest to
        """
        data = json.dumps(self.files, output_file, indent=2)
        data = data.encode("utf8")
        output_file.write(data)

        #for h, filename, perms in self.files:
{'fraction_non_alphanumeric': 0.09477841158402808, 'fraction_numerical': 0.0035103115401491883, 'mean_word_length': 2.2432432432432434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5680784', 'n_tokens_mistral': 626, 'n_tokens_neox': 604, 'n_words': 237}