<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import argparse
import logging

import flaskage
from flaskage.scaffold import Scaffold, ScaffoldException


def valid_project_directory():
    cwd = os.getcwd()
    return (
        os.path.isdir(os.path.join(cwd, 'application')) and
        os.path.isdir(os.path.join(cwd, 'application', 'assets')) and
        os.path.isdir(os.path.join(cwd, 'application', 'models')) and
        os.path.isdir(os.path.join(cwd, 'application', 'static')) and
        os.path.isdir(os.path.join(cwd, 'application', 'templates')) and
        os.path.isdir(os.path.join(cwd, 'application', 'vendor')) and
        os.path.isdir(os.path.join(cwd, 'application', 'views')) and
        os.path.isdir(os.path.join(cwd, 'migrations')) and
        os.path.isdir(os.path.join(cwd, 'libraries')) and
        os.path.isdir(os.path.join(cwd, 'tests')) and
        os.path.isfile(os.path.join(cwd, 'config.py')) and
        os.path.isfile(os.path.join(cwd, 'manage.py'))
    )


def valid_module_name(s):
    return re.match(r'^[a-z_][a-z0-9_]*$', s)


def camelcase(s):
    return ''.join([i.title() or '_' for i in s.split('_')])


def main():
    # Main parser
    parser_main = argparse.ArgumentParser(
        description='Provides the ability to create parts of a Flaskage '
                    'application.'
    )
    subparsers_main = parser_main.add_subparsers(dest='subparser_main_name')

    # Parser for the new command
    parser_new = subparsers_main.add_parser(
        'new', aliases=['n'],
        help='create a new Flaskage project'
    )
    parser_new.add_argument(
        'name', help='the project name in lowercase underscore format'
    )

    # Parser for the generate command
    parser_generate = subparsers_main.add_parser(
        'generate', aliases=['g'],
        help='generate code for an application component'
    )
    subparsers_generate = (
        parser_generate.add_subparsers(dest='subparser_generate_name')
    )

    # Parser for the generate / asset command
    parser_generate_asset = subparsers_generate.add_parser(
        'asset', aliases=['a'],
        help='create a new set of LESS and Coffeescript assets'
    )
    parser_generate_asset.add_argument(
        'name', help='the asset name in lowercase underscore format'
    )

    # Parser for the generate / blueprint command
    parser_generate_blueprint = subparsers_generate.add_parser(
        'blueprint', aliases=['b'],
        help='create a new application component (blueprint)'
    )
    parser_generate_blueprint.add_argument(
        'name', help='the blueprint name in lowercase underscore format'
    )

    # Parser for the generate / model command
    parser_generate_model = subparsers_generate.add_parser(
        'model', aliases=['m'],
        help='create a new database model'
    )
    parser_generate_model.add_argument(
        'name', help='the model name in lowercase underscore format'
    )
    parser_generate_model.add_argument(
        'columns', nargs='*',
        help='column definitions for the new model'
    )

    # Parser for the generate / library command
    parser_generate_library = subparsers_generate.add_parser(
        'library', aliases=['l'],
        help='create a new independent library which is used by your project'
    )
    parser_generate_library.add_argument(
        'name', help='the library name in lowercase underscore format'
    )

    args = parser_main.parse_args()

    # Determine the location of our templates
    template_dir = os.path.abspath(
        os.path.join(
            os.path.dirname(flaskage.__file__), 'templates'
        )
    )
<commit_msg>Ensure that help is printed if no arguments are provided to the flaskage command<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import argparse
import logging

import flaskage
from flaskage.scaffold import Scaffold, ScaffoldException


def valid_project_directory():
    cwd = os.getcwd()
    return (
        os.path.isdir(os.path.join(cwd, 'application')) and
        os.path.isdir(os.path.join(cwd, 'application', 'assets')) and
        os.path.isdir(os.path.join(cwd, 'application', 'models')) and
        os.path.isdir(os.path.join(cwd, 'application', 'static')) and
        os.path.isdir(os.path.join(cwd, 'application', 'templates')) and
        os.path.isdir(os.path.join(cwd, 'application', 'vendor')) and
        os.path.isdir(os.path.join(cwd, 'application', 'views')) and
        os.path.isdir(os.path.join(cwd, 'migrations')) and
        os.path.isdir(os.path.join(cwd, 'libraries')) and
        os.path.isdir(os.path.join(cwd, 'tests')) and
        os.path.isfile(os.path.join(cwd, 'config.py')) and
        os.path.isfile(os.path.join(cwd, 'manage.py'))
    )


def valid_module_name(s):
    return re.match(r'^[a-z_][a-z0-9_]*$', s)


def camelcase(s):
    return ''.join([i.title() or '_' for i in s.split('_')])


def main():
    # Main parser
    parser_main = argparse.ArgumentParser(
        description='Provides the ability to create parts of a Flaskage '
                    'application.'
    )
    subparsers_main = parser_main.add_subparsers(dest='subparser_main_name')

    # Parser for the new command
    parser_new = subparsers_main.add_parser(
        'new', aliases=['n'],
        help='create a new Flaskage project'
    )
    parser_new.add_argument(
        'name', help='the project name in lowercase underscore format'
    )

    # Parser for the generate command
    parser_generate = subparsers_main.add_parser(
        'generate', aliases=['g'],
        help='generate code for an application component'
    )
    subparsers_generate = (
        parser_generate.add_subparsers(dest='subparser_generate_name')
    )

    # Parser for the generate / asset command
    parser_generate_asset = subparsers_generate.add_parser(
        'asset', aliases=['a'],
        help='create a new set of LESS and Coffeescript assets'
    )
    parser_generate_asset.add_argument(
        'name', help='the asset name in lowercase underscore format'
    )

    # Parser for the generate / blueprint command
    parser_generate_blueprint = subparsers_generate.add_parser(
        'blueprint', aliases=['b'],
        help='create a new application component (blueprint)'
    )
    parser_generate_blueprint.add_argument(
        'name', help='the blueprint name in lowercase underscore format'
    )

    # Parser for the generate / model command
    parser_generate_model = subparsers_generate.add_parser(
        'model', aliases=['m'],
        help='create a new database model'
    )
    parser_generate_model.add_argument(
        'name', help='the model name in lowercase underscore format'
    )
    parser_generate_model.add_argument(
        'columns', nargs='*',
        help='column definitions for the new model'
    )

    # Parser for the generate / library command
    parser_generate_library = subparsers_generate.add_parser(
        'library', aliases=['l'],
        help='create a new independent library which is used by your project'
    )
    parser_generate_library.add_argument(
        'name', help='the library name in lowercase underscore format'
    )

    args = parser_main.parse_args()

    # Print help if no arguments are provided
    if not args.subparser_main_name:
        parser_main.print_help()
        parser_main.exit()
    elif (
        args.subparser_main_name in ['generate', 'g'] and
        not args.subparser_generate_name
    ):
        parser_generate.print_help()
        parser_generate.exit()

    # Determine the location of our templates
    template_dir = os.path.abspath(
        os.path.join(
            os.path.dirname(flaskage.__file__), 'templates'
        )
    )

{'fraction_non_alphanumeric': 0.11630602782071098, 'fraction_numerical': 0.0007727975270479134, 'mean_word_length': 2.988186954288649, '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': '4248969', 'n_tokens_mistral': 2447, 'n_tokens_neox': 2409, 'n_words': 567}