<commit_before>import os
from ..target import Target

class LocalFile(Target):
    def __init__(self, path):
        self._path = path
        super(LocalFile, self).__init__()
        self._timestamp = 0

    def identifier(self):
        return self._path

    def exists(self):
        return os.path.exists(self._path)

    def path(self):
        return self._path

    def open(self, *args, **kwargs):
        return open(self._path, *args, **kwargs)

    def store(self, batch=None):
        if self.exists():
            self._memory['timestamp'] = os.path.getmtime(self._path)
        else:
            self._memory['timestamp'] = 0
        super(LocalFile, self).store(batch)

    def is_damaged(self):
        stored = self.stored()
        if stored is None:
            return True
        if self.exists():
            return os.path.getmtime(self._path) > stored['timestamp']
        else:
            return True
<commit_msg>Fix unnecessary recomputation of file targets<commit_after>import os
from ..target import Target

class LocalFile(Target):
    def __init__(self, path):
        self._path = path
        super(LocalFile, self).__init__()
        if self.exists():
            self._memory['timestamp'] = os.path.getmtime(self._path)
        else:
            self._memory['timestamp'] = 0

    def identifier(self):
        return self._path

    def exists(self):
        return os.path.exists(self._path)

    def path(self):
        return self._path

    def store(self, batch=None):
        if self.exists():
            self._memory['timestamp'] = os.path.getmtime(self._path)
        else:
            self._memory['timestamp'] = 0
        super(LocalFile, self).store(batch)

    def open(self, *args, **kwargs):
        return open(self._path, *args, **kwargs)

    def is_damaged(self):
        mem = self.stored()
        if mem is None or not 'timestamp' in mem:
            return True

        return self._memory['timestamp'] > mem['timestamp']

{'fraction_non_alphanumeric': 0.11945564516129033, 'fraction_numerical': 0.0020161290322580645, 'mean_word_length': 2.1964573268921095, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6588015', 'n_tokens_mistral': 580, 'n_tokens_neox': 562, 'n_words': 144}