<commit_before>import os
from shutil import copyfile


class AlreadyExists(Exception):
    pass


class Resource(object):

    def __init__(self, source, path):
        self.source = source
        self.path = path

    def destination_path(self, context):
        return self.path.format(**context)

    def __repr__(self):
        return '<{0} {1}>'.format(self.__class__.__name__, self.path)


class Directory(Resource):

    def copy(self, destination, context):
        destination_path = self.destination_path(context)
        destination = os.path.join(destination, destination_path)
        if os.path.exists(destination):
            if self.path != '.':
                raise AlreadyExists('directory already exists')
        else:
            os.makedirs(destination, 0755)


class File(Resource):

    def copy(self, destination, context):
        destination_path = self.destination_path(context)
        destination = os.path.join(destination, destination_path)
        source = os.path.join(self.source, self.path)
        copyfile(source, destination)


class Template(Resource):

    def destination_path(self, context):
        return super(self, Template).destination_path(context)[:-5]

    def copy(self, destination, context):
        destination_path = self.destination_path(context)
        destination = os.path.join(destination, destination_path)
        source = os.path.join(self.source, self.path)
        with open(source) as f:
            content = f.read()
        with open(destination, 'w') as f:
            f.write(content.format(**context))<commit_msg>Fix Template's destination_path method<commit_after>import os
from shutil import copyfile


class AlreadyExists(Exception):
    pass


class Resource(object):

    def __init__(self, source, path):
        self.source = source
        self.path = path

    def destination_path(self, context):
        return self.path.format(**context)

    def __repr__(self):
        return '<{0} {1}>'.format(self.__class__.__name__, self.path)


class Directory(Resource):

    def copy(self, destination, context):
        destination_path = self.destination_path(context)
        destination = os.path.join(destination, destination_path)
        if os.path.exists(destination):
            if self.path != '.':
                raise AlreadyExists('directory already exists')
        else:
            os.makedirs(destination, 0755)


class File(Resource):

    def copy(self, destination, context):
        destination_path = self.destination_path(context)
        destination = os.path.join(destination, destination_path)
        source = os.path.join(self.source, self.path)
        copyfile(source, destination)


class Template(Resource):

    def destination_path(self, context):
        return super(Template, self).destination_path(context)[:-5]

    def copy(self, destination, context):
        destination_path = self.destination_path(context)
        destination = os.path.join(destination, destination_path)
        source = os.path.join(self.source, self.path)
        with open(source) as f:
            content = f.read()
        with open(destination, 'w') as f:
            f.write(content.format(**context))
{'fraction_non_alphanumeric': 0.1095163806552262, 'fraction_numerical': 0.00436817472698908, 'mean_word_length': 2.9482758620689653, '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': '1030831', 'n_tokens_mistral': 902, 'n_tokens_neox': 856, 'n_words': 202}