<commit_before>from __future__ import absolute_import

from django.core.management.base import BaseCommand

from zerver.lib.actions import do_rename_stream
from zerver.models import Realm, get_realm

class Command(BaseCommand):
    help = """Change the stream name for a realm.

Usage: python manage.py rename-stream <domain> <old name> <new name>"""

    def handle(self, *args, **options):
        if len(args) != 3:
            print "Please provide a domain and the old and new names."
            exit(1)

        domain, old_name, new_name = args

        try:
            realm = get_realm(domain)
        except Realm.DoesNotExist:
            print "Unknown domain %s" % (domain,)
            exit(1)

        do_rename_stream(realm, old_name, new_name)
<commit_msg>rename-stream: support non-ASCII stream names.<commit_after>from __future__ import absolute_import

from django.core.management.base import BaseCommand

from zerver.lib.actions import do_rename_stream
from zerver.models import Realm, get_realm

import sys

class Command(BaseCommand):
    help = """Change the stream name for a realm.

Usage: python manage.py rename-stream <domain> <old name> <new name>"""

    def handle(self, *args, **options):
        if len(args) != 3:
            print "Please provide a domain and the old and new names."
            exit(1)

        domain, old_name, new_name = args
        encoding = sys.getfilesystemencoding()

        try:
            realm = get_realm(domain)
        except Realm.DoesNotExist:
            print "Unknown domain %s" % (domain,)
            exit(1)

        do_rename_stream(realm, old_name.decode(encoding),
                         new_name.decode(encoding))

{'fraction_non_alphanumeric': 0.09053497942386832, 'fraction_numerical': 0.003527336860670194, 'mean_word_length': 2.7, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5704182', 'n_tokens_mistral': 503, 'n_tokens_neox': 490, 'n_words': 154}