<commit_before>#!/usr/bin/python
# -*- coding:utf-8 -*-
import functools
import inspect
import os

from .exceptions import InvalidFileName, InvalidFolderName, RootPathDoesNotExists
from .templates import blank_template


def name_validator(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        func_args = inspect.getcallargs(func, *args, **kwargs)

        if func_args.get('validate'):
            _filter = "!@#$%^&*()-+=[]{}|\"'."
            name = func_args.get('name')

            if len(list(set(list(name)).intersection(list(_filter)))) > 0 or name[0].isdigit():
                exception = 'Invalid'+func.__name__.split('_')[1].title()+'Name'
                raise globals()[exception]

        return func(*args, **kwargs)
    return wrapper


class Creator(object):

    root_path = None

    def __init__(self, root_path):
        if not os.path.isdir(root_path):
            raise RootPathDoesNotExists
        self.root_path = root_path

    @name_validator
    def create_file(self, _path, name, template, validate=True):
        file_path = os.path.join(_path, name)
        with open(file_path, 'w') as _file:
            _file.write(template)

    @name_validator<commit_msg>fix bug<commit_after>#!/usr/bin/python
# -*- coding:utf-8 -*-
import functools
import inspect
import os

from .exceptions import InvalidFileName, InvalidFolderName, RootPathDoesNotExists
from .templates import blank_template


def name_validator(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        func_args = inspect.getcallargs(func, *args, **kwargs)

        if func_args.get('validate'):
            _filter = "!@#$%^&*()-+=[]{}|\"'."
            name = func_args.get('name').replace('.py', '')

            if len(list(set(list(name)).intersection(list(_filter)))) > 0 or name[0].isdigit():
                exception = 'Invalid'+func.__name__.split('_')[1].title()+'Name'
                raise globals()[exception]

        return func(*args, **kwargs)
    return wrapper


class Creator(object):

    root_path = None

    def __init__(self, root_path):
        if not os.path.isdir(root_path):
            raise RootPathDoesNotExists
        self.root_path = root_path

    @name_validator
    def create_file(self, _path, name, template, validate=True):
        file_path = os.path.join(_path, name)
        with open(file_path, 'w') as _file:
            _file.write(template)

    @name_validator
{'fraction_non_alphanumeric': 0.14180629342051493, 'fraction_numerical': 0.0032693093583980384, 'mean_word_length': 2.929373996789727, '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': '1739059', 'n_tokens_mistral': 771, 'n_tokens_neox': 750, 'n_words': 156}