<commit_before>"""templer.django_project_app"""
import os

from templer.core.vars import StringVar
from templer.core.vars import BooleanVar
from templer.core.base import BaseTemplate
from templer.core.structures import Structure


HELP_TEXT = """
This creates a basic skeleton for a Django application within a project.
"""

POST_RUN_MESSAGE = """
Now you can install your application into your project by adding these lines.

in %(project_root_path)surls.py:

  url(r'^%(egg)s/', include('%(project_root_module)s%(egg)s.urls')),

in %(project_root_path)ssettings.py:

  INSTALLED_APPS = (
    ...
    '%(project_root_module)s%(egg)s',
    ...)
"""

MODEL_VAR = StringVar(
    'model',
    title='Model name',
    description='Default name of the model',
    default='Model',
    help='The name of the Model should be in singular form '
    'and in CapitalizedWords format.'
)

MANAGEMENT_COMMAND_VAR = BooleanVar(
    'add_management_command',
    title='Add management command',
    description='Should the application have management command ?',
    default=False,
    structures={'False': None, 'True': 'management_command'},
    help='This will create the structure for adding management '
    'commands to your application.'
)


class ManagementCommandStructure(Structure):
    _structure_dir = 'structures/management_command'


class DjangoProjectApp(BaseTemplate):
    _template_dir = 'templates/django_project_app'
    summary = 'A basic Django project application skeleton within a project'
    help = HELP_TEXT
    category = 'Django'
    use_cheetah = True
    vars = [MODEL_VAR, MANAGEMENT_COMMAND_VAR]

    def pre(self, command, output_dir, vars):
        super(DjangoProjectApp, self).pre(
            command, output_dir, vars)
        vars['project_root'] = os.path.split(os.getcwd())[-1]
        vars['project_root_path'] = '%s/' % vars['project_root']
        vars['project_root_module'] = '%s.' % vars['project_root']
        vars['model_lower'] = vars['model'].lower()

    def post(self, command, output_dir, vars):
        # Don't set the message to self.post_run_msg because the output
        # is really ugly. Simply rename the next assignment to change
        # this behavior.
        self.post_run_message = POST_RUN_MESSAGE % vars
        print self.post_run_message
        super(DjangoProjectApp, self).post(
            command, output_dir, vars)<commit_msg>Add declinaison of a Django app not within a project<commit_after>"""templer.django_project_app"""
import os

from templer.core.vars import StringVar
from templer.core.vars import BooleanVar
from templer.core.base import BaseTemplate
from templer.core.structures import Structure


HELP_TEXT = """
This creates a basic skeleton for a Django application within a project.
"""

POST_RUN_MESSAGE = """
Now you can install your application into your project by adding these lines.

in %(project_root_path)surls.py:

  url(r'^%(egg)s/', include('%(project_root_module)s%(egg)s.urls')),

in %(project_root_path)ssettings.py:

  INSTALLED_APPS = (
    ...
    '%(project_root_module)s%(egg)s',
    ...)
"""

MODEL_VAR = StringVar(
    'model',
    title='Model name',
    description='Default name of the model',
    default='Model',
    help='The name of the Model should be in singular form '
    'and in CapitalizedWords format.'
)

MANAGEMENT_COMMAND_VAR = BooleanVar(
    'add_management_command',
    title='Add management command',
    description='Should the application have management command ?',
    default=False,
    structures={'False': None, 'True': 'management_command'},
    help='This will create the structure for adding management '
    'commands to your application.'
)


class ManagementCommandStructure(Structure):
    _structure_dir = 'structures/management_command'


class DjangoProjectApp(BaseTemplate):
    _template_dir = 'templates/django_project_app'
    summary = 'A basic Django project application skeleton within a project'
    help = HELP_TEXT
    category = 'Django'
    use_cheetah = True
    vars = [MODEL_VAR, MANAGEMENT_COMMAND_VAR]

    def pre(self, command, output_dir, vars):
        super(DjangoProjectApp, self).pre(
            command, output_dir, vars)
        vars['project_root'] = os.path.split(os.getcwd())[-1]
        vars['project_root_path'] = '%s/' % vars['project_root']
        vars['project_root_module'] = '%s.' % vars['project_root']
        vars['model_lower'] = vars['model'].lower()

    def post(self, command, output_dir, vars):
        # Don't set the message to self.post_run_msg because the output
        # is really ugly. Simply rename the next assignment to change
        # this behavior.
        self.post_run_message = POST_RUN_MESSAGE % vars
        print self.post_run_message
        super(DjangoProjectApp, self).post(
            command, output_dir, vars)


class DjangoApp(DjangoProjectApp):
    summary = 'A basic Django project application skeleton'

    def pre(self, command, output_dir, vars):
        super(DjangoApp, self).pre(
            command, output_dir, vars)
        vars['project_root'] = ''
        vars['project_root_path'] = ''
        vars['project_root_module'] = ''
{'fraction_non_alphanumeric': 0.11035686578743212, 'fraction_numerical': 0.0003878975950349108, 'mean_word_length': 3.7442502299908003, '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': '662957', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1496, 'n_words': 412}