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

"""
cookiecutter.main
-----------------

Main entry point for the `cookiecutter` command.

The code in this module is also a good example of how to use Cookiecutter as a
library rather than a script.
"""

from __future__ import unicode_literals
import logging
import os
import re

from .config import get_user_config
from .exceptions import InvalidModeException
from .prompt import prompt_for_config
from .generate import generate_context, generate_files
from .vcs import clone
from .replay import dump, load

logger = logging.getLogger(__name__)

builtin_abbreviations = {
    'gh': 'https://github.com/{0}.git',
    'bb': 'https://bitbucket.org/{0}',
}

REPO_REGEX = """
(
(\w+:(//)?)          # something like git:// ssh:// etc.
 |                   # or
 (\w+@[\w\.]+)       # something like user@...
)
.*
"""


def is_repo_url(value):
    """Return True if value is a repository URL."""
    return bool(re.match(REPO_REGEX, value, re.VERBOSE))


def expand_abbreviations(template, config_dict):
    """
    Expand abbreviations in a template name.

    :param template: The project template name.
    :param config_dict: The user config, which will contain abbreviation
        definitions.<commit_msg>Be explicit about valid repo_urls<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
cookiecutter.main
-----------------

Main entry point for the `cookiecutter` command.

The code in this module is also a good example of how to use Cookiecutter as a
library rather than a script.
"""

from __future__ import unicode_literals
import logging
import os
import re

from .config import get_user_config
from .exceptions import InvalidModeException
from .prompt import prompt_for_config
from .generate import generate_context, generate_files
from .vcs import clone
from .replay import dump, load

logger = logging.getLogger(__name__)

builtin_abbreviations = {
    'gh': 'https://github.com/{0}.git',
    'bb': 'https://bitbucket.org/{0}',
}

REPO_REGEX = """
(
((git|ssh|https|http):(//)?)    # something like git:// ssh:// etc.
 |                              # or
 (\w+@[\w\.]+)                  # something like user@...
)
.*
"""


def is_repo_url(value):
    """Return True if value is a repository URL."""
    return bool(re.match(REPO_REGEX, value, re.VERBOSE))


def expand_abbreviations(template, config_dict):
    """
    Expand abbreviations in a template name.

    :param template: The project template name.
    :param config_dict: The user config, which will contain abbreviation
        definitions.
{'fraction_non_alphanumeric': 0.13006561173292167, 'fraction_numerical': 0.0023157082207641835, 'mean_word_length': 3.1538461538461537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '5132448', 'n_tokens_mistral': 797, 'n_tokens_neox': 763, 'n_words': 259}