<commit_before>from __future__ import absolute_import

from django.core.management.base import BaseCommand
from zephyr.lib.actions import do_create_realm

class Command(BaseCommand):
    help = "Create a realm for the specified domain(s)."

    def handle(self, *args, **options):
        for domain in args:
            realm, created = do_create_realm(domain)
            if created:
                print domain + ": Created."
            else:
                print domain + ": Already exists."
<commit_msg>create_realm: be able to specify an open realm.<commit_after>from __future__ import absolute_import
from optparse import make_option

from django.core.management.base import BaseCommand
from zephyr.lib.actions import do_create_realm

class Command(BaseCommand):
    help = """Create a realm for the specified domain.

Usage: python manage.py create_realm foo.com"""

    option_list = BaseCommand.option_list + (
        make_option('-o', '--open-realm',
                    dest='open_realm',
                    action="store_true",
                    default=False,
                    help='Make this an open realm.'),
        )

    def handle(self, *args, **options):
        if not args:
            self.print_help("python manage.py", "create_realm")
            exit(1)

        domain = args[0]
        realm, created = do_create_realm(
            domain, restricted_to_domain=not options["open_realm"])
        if created:
            print domain, "created."
        else:
            print domain, "already exists."
{'fraction_non_alphanumeric': 0.09149902660609993, 'fraction_numerical': 0.0012978585334198572, 'mean_word_length': 2.3304535637149026, 'pattern_counts': {'":': 2, '<': 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': '3302263', 'n_tokens_mistral': 421, 'n_tokens_neox': 409, 'n_words': 122}