<commit_before>import os
import hashlib


class Hasher(object):
    def __init__(self):
        self._hash = hashlib.sha1()
    
    def update(self, arg):
        self._hash.update(_sha1(arg))
    
    def update_with_dir(self, dir_path):
        for file_path in _all_files(dir_path):
            self.update(os.path.relpath(file_path, dir_path))
            self.update(open(file_path).read())
    
    def ascii_digest(self):
        return integer_to_ascii(int(self._hash.hexdigest(), 16))


def integer_to_ascii(value):
    characters = "0123456789abcdefghijklmnopqrstuvwxyz"
    
    if value == 0:<commit_msg>Close files properly when hashing<commit_after>import os
import hashlib


class Hasher(object):
    def __init__(self):
        self._hash = hashlib.sha1()
    
    def update(self, arg):
        self._hash.update(_sha1(arg))
    
    def update_with_dir(self, dir_path):
        for file_path in _all_files(dir_path):
            self.update(os.path.relpath(file_path, dir_path))
            with open(file_path) as f:
                self.update(f.read())
    
    def ascii_digest(self):
        return integer_to_ascii(int(self._hash.hexdigest(), 16))


def integer_to_ascii(value):
    characters = "0123456789abcdefghijklmnopqrstuvwxyz"
    
    if value == 0:
{'fraction_non_alphanumeric': 0.10678098207326578, 'fraction_numerical': 0.02338269680436477, 'mean_word_length': 2.879154078549849, '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': '457526', 'n_tokens_mistral': 467, 'n_tokens_neox': 429, 'n_words': 79}