<commit_before>import os
import re
import sys
import traceback

from collections import defaultdict
from optparse import make_option
from subprocess import Popen, PIPE

from django.db import connections, router, transaction, DEFAULT_DB_ALIAS
from django.db.models import get_model
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError
from django.core.management.sql import emit_post_sync_signal
from django.utils.importlib import import_module

from nashvegas.models import Migration
from nashvegas.utils import get_sql_for_new_models


sys.path.append("migrations")
MIGRATION_NAME_RE = re.compile(r"(\d+)(.*)")


class Transactional(object):
    def __enter__(self):
        for db in connections:
            # enter transaction management
            transaction.enter_transaction_management(using=db)
            transaction.managed(True, using=db)
    
    def __exit__(self, exc_type, exc_value, traceback):
        for db in connections:
            if exc_type:
                transaction.rollback(using=db)
            else:
                transaction.commit(using=db)
            transaction.leave_transaction_management(using=db)


class MigrationError(Exception):
    pass


class Command(BaseCommand):
    
    option_list = BaseCommand.option_list + (
        make_option("-l", "--list", action="store_true",
                    dest="do_list", default=False,
                    help="Enumerate the list of migrations to execute."),
        make_option("-e", "--execute", action="store_true",
                    dest="do_execute", default=False,
                    help="Execute migrations not in versions table."),
        make_option("-c", "--create", action="store_true",
                    dest="do_create", default=False,
                    help="Generates sql for models that are installed but not in your database."),
        make_option("--create-all", action="store_true",
                    dest="do_create_all", default=False,
                    help="Generates sql for models that are installed but not in your database."),
        make_option("-s", "--seed", action="store_true",
                    dest="do_seed", default=False,
                    help="Seed nashvegas with migrations that have previously been applied in another manner."),
        make_option("-d", "--database", action="store", dest="database",
                    help="Nominates a database to synchronize."),
        make_option("--noinput", action="store_false", dest="interactive", default=True,
                    help="Tells Django to NOT prompt the user for input of any kind."),
        make_option("-p", "--path", dest="path",
                    default=None,
                    help="The path to the database migration scripts."))
    
    help = "Upgrade database."
    
    def _get_capable_databases(self):
        """
        Returns a list of databases which are capable of supporting
        Nashvegas (based on their routing configuration).
        """
        for database in connections:<commit_msg>Default interactivity to False<commit_after>import os
import re
import sys
import traceback

from collections import defaultdict
from optparse import make_option
from subprocess import Popen, PIPE

from django.db import connections, router, transaction, DEFAULT_DB_ALIAS
from django.db.models import get_model
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError
from django.core.management.sql import emit_post_sync_signal
from django.utils.importlib import import_module

from nashvegas.models import Migration
from nashvegas.utils import get_sql_for_new_models


sys.path.append("migrations")
MIGRATION_NAME_RE = re.compile(r"(\d+)(.*)")


class Transactional(object):
    def __enter__(self):
        for db in connections:
            # enter transaction management
            transaction.enter_transaction_management(using=db)
            transaction.managed(True, using=db)
    
    def __exit__(self, exc_type, exc_value, traceback):
        for db in connections:
            if exc_type:
                transaction.rollback(using=db)
            else:
                transaction.commit(using=db)
            transaction.leave_transaction_management(using=db)


class MigrationError(Exception):
    pass


class Command(BaseCommand):
    
    option_list = BaseCommand.option_list + (
        make_option("-l", "--list", action="store_true",
                    dest="do_list", default=False,
                    help="Enumerate the list of migrations to execute."),
        make_option("-e", "--execute", action="store_true",
                    dest="do_execute", default=False,
                    help="Execute migrations not in versions table."),
        make_option("-c", "--create", action="store_true",
                    dest="do_create", default=False,
                    help="Generates sql for models that are installed but not in your database."),
        make_option("--create-all", action="store_true",
                    dest="do_create_all", default=False,
                    help="Generates sql for models that are installed but not in your database."),
        make_option("-s", "--seed", action="store_true",
                    dest="do_seed", default=False,
                    help="Seed nashvegas with migrations that have previously been applied in another manner."),
        make_option("-d", "--database", action="store", dest="database",
                    help="Nominates a database to synchronize."),
        make_option("--noinput", action="store_false", dest="interactive", default=False,
                    help="Tells Django to NOT prompt the user for input of any kind."),
        make_option("-p", "--path", dest="path",
                    default=None,
                    help="The path to the database migration scripts."))
    
    help = "Upgrade database."
    
    def _get_capable_databases(self):
        """
        Returns a list of databases which are capable of supporting
        Nashvegas (based on their routing configuration).
        """
        for database in connections:
{'fraction_non_alphanumeric': 0.0970625798212005, 'fraction_numerical': 0.0, 'mean_word_length': 2.6339907192575405, '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': '2546694', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1572, 'n_words': 470}