<commit_before>"""
scrapple.commands.genconfig
~~~~~~~~~~~~~~~~~~~~~~~~~~~

"""

from __future__ import print_function
from jinja2 import Template
import os
import json
from colorama import init, Fore, Back

import scrapple
from scrapple.commands import command

class GenconfigCommand(command.Command):
    """
    Defines the execution of :command: genconfig
    """

    def __init__(self, args):
        self.args = args
        init()

    def execute_command(self):
        """
        Execution method of :command: genconfig
        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Genconfig")
        print(Back.RESET + Fore.RESET)
        directory = os.path.join(scrapple.__path__[0], 'templates', 'configs')
        with open(os.path.join(directory, self.args['--type'] + '.txt'), 'r') as f:
            template_content = f.read()
        print("\n\nUsing the", self.args['--type'], "template\n\n")
        template = Template(template_content)
        settings = {
            'projectname': self.args['<projectname>'],
            'selector_type': self.args['--selector'],
            'url': self.args['<url>']
        }
        rendered = template.render(settings=settings)
        json_content = eval(rendered)
        with open(self.args['<projectname>'] + '.json', 'w') as f:
            json.dump(json_content, f)
        print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json has been created" \
            + Back.RESET + Fore.RESET, sep="")<commit_msg>Modify genconfig to retain indentation of template<commit_after>"""
scrapple.commands.genconfig
~~~~~~~~~~~~~~~~~~~~~~~~~~~

"""

from __future__ import print_function
from jinja2 import Template
import os
from colorama import init, Fore, Back

import scrapple
from scrapple.commands import command

class GenconfigCommand(command.Command):
    """
    Defines the execution of :command: genconfig
    """

    def __init__(self, args):
        self.args = args
        init()

    def execute_command(self):
        """
        Execution method of :command: genconfig
        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Genconfig")
        print(Back.RESET + Fore.RESET)
        directory = os.path.join(scrapple.__path__[0], 'templates', 'configs')
        with open(os.path.join(directory, self.args['--type'] + '.txt'), 'r') as f:
            template_content = f.read()
        print("\n\nUsing the", self.args['--type'], "template\n\n")
        template = Template(template_content)
        settings = {
            'projectname': self.args['<projectname>'],
            'selector_type': self.args['--selector'],
            'url': self.args['<url>']
        }
        rendered = template.render(settings=settings)
        with open(self.args['<projectname>'] + '.json', 'w') as f:
            f.write(rendered)
        print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json has been created" \
            + Back.RESET + Fore.RESET, sep="")
{'fraction_non_alphanumeric': 0.15899864682002707, 'fraction_numerical': 0.0013531799729364006, 'mean_word_length': 2.719496855345912, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5913114', 'n_tokens_mistral': 863, 'n_tokens_neox': 864, 'n_words': 202}