<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import os
import sys

from jinja2 import (
    Environment, FileSystemLoader, TemplateError,
    # ChoiceLoader, PackageLoader
)

from yeopy import tools

logger = logging.getLogger(__name__)


class Generator(object):

    def __init__(self, pname):
        self.pname = pname
        self.user_dir = os.getcwd()
        self.project_root_dir = os.path.join(self.user_dir, pname)

        try:
            # self.env = Environment(loader=ChoiceLoader([
            #     FileSystemLoader('templates'),
            #     PackageLoader('yeopy', 'templates'),
            # ]))
            self.env = Environment(loader=FileSystemLoader(
                os.path.join(os.path.dirname(__file__), 'templates')
            ))

            self.templates = {
                'readme': self.env.get_template('readme.tpl'),
            }
        except TemplateError as e:
            logging.error(str(e))
            sys.exit(1)

    def gen_root_dir(self):
        os.mkdir(os.path.join(self.user_dir, self.pname))
        logger.info('Generate root directory.')

    def gen_readme(self):
        confs = {
            'pname': self.pname,
        }
        _path = os.path.join(self.project_root_dir, 'README.md')
        # prepare to render confs
        render_result = self.templates['readme'].render(confs)
        logger.debug('readme result: ' + render_result)
        # prepare to write this result to README.md
        tools.write_file(_path, render_result)
        logger.info('Generate README.md.')

    def gen_tests(self):
        pass

    def gen_requirements(self):
        pass

    def gen_fabfile(self):
        pass

    def gen_app(self):
        pass

    def gen_tools(self):
        pass

    def gen_handlers(self):
        pass

    def gen_models(self):
        pass

    def gen_controlers(self):
        pass

    def gen_exceptions(self):
        pass

    def gen_log(self):
        pass

    def gen_consts(self):
        pass
<commit_msg>fix bug<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import os
import sys

from jinja2 import (
    Environment, FileSystemLoader, TemplateError,
    # ChoiceLoader, PackageLoader
)

from yeopy import tools

logger = logging.getLogger(__name__)


class Generator(object):

    def __init__(self, pname):
        self.pname = pname
        self.user_dir = os.getcwd()
        self.project_root_dir = os.path.join(self.user_dir, pname)

        try:
            # self.env = Environment(loader=ChoiceLoader([
            #     FileSystemLoader('templates'),
            #     PackageLoader('yeopy', 'templates'),
            # ]))
            self.env = Environment(loader=FileSystemLoader(
                os.path.join(os.path.dirname(__file__), 'templates')
            ))

            self.templates = {
                'readme': self.env.get_template('readme.tpl'),
            }
        except TemplateError as e:
            logging.error(str(e))
            sys.exit(1)

    def gen_root_dir(self):
        if tools.check_path_exists(os.path.join(self.user_dir, self.pname)):
            logger.error('Path exist.')
            sys.exit(1)
        os.mkdir(os.path.join(self.user_dir, self.pname))
        logger.info('Generate root directory.')

    def gen_readme(self):
        confs = {
            'pname': self.pname,
        }
        _path = os.path.join(self.project_root_dir, 'README.md')
        # prepare to render confs
        render_result = self.templates['readme'].render(confs)
        logger.debug('readme result: ' + render_result)
        # prepare to write this result to README.md
        tools.write_file(_path, render_result)
        logger.info('Generate README.md.')

    def gen_tests(self):
        pass

    def gen_requirements(self):
        pass

    def gen_fabfile(self):
        pass

    def gen_app(self):
        pass

    def gen_tools(self):
        pass

    def gen_handlers(self):
        pass

    def gen_models(self):
        pass

    def gen_controlers(self):
        pass

    def gen_exceptions(self):
        pass

    def gen_log(self):
        pass

    def gen_consts(self):
        pass

{'fraction_non_alphanumeric': 0.10992655768775171, 'fraction_numerical': 0.001658374792703151, 'mean_word_length': 2.0200286123032902, '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': '7267478', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1265, 'n_words': 253}