[py3] Replaced raw_input by input
The six addition has been borrowed from: https://bitbucket.org/gutworth/six/changeset/733ef740
This commit is contained in:
parent
b1517a310a
commit
b8e49d70f2
|
@ -9,6 +9,7 @@ import unicodedata
|
|||
from django.contrib.auth import models as auth_app
|
||||
from django.db.models import get_models, signals
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.six.moves import input
|
||||
|
||||
|
||||
def _get_permission_codename(action, opts):
|
||||
|
@ -66,10 +67,10 @@ def create_superuser(app, created_models, verbosity, db, **kwargs):
|
|||
msg = ("\nYou just installed Django's auth system, which means you "
|
||||
"don't have any superusers defined.\nWould you like to create one "
|
||||
"now? (yes/no): ")
|
||||
confirm = raw_input(msg)
|
||||
confirm = input(msg)
|
||||
while 1:
|
||||
if confirm not in ('yes', 'no'):
|
||||
confirm = raw_input('Please enter either "yes" or "no": ')
|
||||
confirm = input('Please enter either "yes" or "no": ')
|
||||
continue
|
||||
if confirm == 'yes':
|
||||
call_command("createsuperuser", interactive=True, database=db)
|
||||
|
|
|
@ -12,6 +12,7 @@ from django.contrib.auth.management import get_default_username
|
|||
from django.core import exceptions
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.db import DEFAULT_DB_ALIAS
|
||||
from django.utils.six.moves import input
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
RE_VALID_USERNAME = re.compile('[\w.@+-]+$')
|
||||
|
@ -76,7 +77,7 @@ class Command(BaseCommand):
|
|||
input_msg = 'Username'
|
||||
if default_username:
|
||||
input_msg += ' (leave blank to use %r)' % default_username
|
||||
username = raw_input(input_msg + ': ')
|
||||
username = input(input_msg + ': ')
|
||||
if default_username and username == '':
|
||||
username = default_username
|
||||
if not RE_VALID_USERNAME.match(username):
|
||||
|
@ -94,7 +95,7 @@ class Command(BaseCommand):
|
|||
# Get an email
|
||||
while 1:
|
||||
if not email:
|
||||
email = raw_input('E-mail address: ')
|
||||
email = input('E-mail address: ')
|
||||
try:
|
||||
is_valid_email(email)
|
||||
except exceptions.ValidationError:
|
||||
|
|
|
@ -2,6 +2,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.db.models import get_apps, get_models, signals
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils import six
|
||||
from django.utils.six.moves import input
|
||||
|
||||
def update_contenttypes(app, created_models, verbosity=2, **kwargs):
|
||||
"""
|
||||
|
@ -49,7 +50,7 @@ def update_contenttypes(app, created_models, verbosity=2, **kwargs):
|
|||
' %s | %s' % (ct.app_label, ct.model)
|
||||
for ct in to_remove
|
||||
])
|
||||
ok_to_delete = raw_input("""The following content types are stale and need to be deleted:
|
||||
ok_to_delete = input("""The following content types are stale and need to be deleted:
|
||||
|
||||
%s
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ from django.core.files.storage import FileSystemStorage
|
|||
from django.core.management.base import CommandError, NoArgsCommand
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.six.moves import input
|
||||
|
||||
from django.contrib.staticfiles import finders, storage
|
||||
|
||||
|
@ -148,7 +149,7 @@ class Command(NoArgsCommand):
|
|||
clear_display = 'This will overwrite existing files!'
|
||||
|
||||
if self.interactive:
|
||||
confirm = raw_input("""
|
||||
confirm = input("""
|
||||
You have requested to collect static files at the destination
|
||||
location as specified in your settings%s
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ from django.core.management.base import NoArgsCommand, CommandError
|
|||
from django.core.management.color import no_style
|
||||
from django.core.management.sql import sql_flush, emit_post_sync_signal
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.six.moves import input
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
|
@ -45,7 +46,7 @@ class Command(NoArgsCommand):
|
|||
sql_list = sql_flush(self.style, connection, only_django=True, reset_sequences=reset_sequences)
|
||||
|
||||
if interactive:
|
||||
confirm = raw_input("""You have requested a flush of the database.
|
||||
confirm = input("""You have requested a flush of the database.
|
||||
This will IRREVERSIBLY DESTROY all data currently in the %r database,
|
||||
and return each table to the state it was in after syncdb.
|
||||
Are you sure you want to do this?
|
||||
|
|
|
@ -3,6 +3,7 @@ import time
|
|||
|
||||
from django.conf import settings
|
||||
from django.db.utils import load_backend
|
||||
from django.utils.six.moves import input
|
||||
|
||||
# The prefix to put on the default database name when creating
|
||||
# the test database.
|
||||
|
@ -330,7 +331,7 @@ class BaseDatabaseCreation(object):
|
|||
sys.stderr.write(
|
||||
"Got an error creating the test database: %s\n" % e)
|
||||
if not autoclobber:
|
||||
confirm = raw_input(
|
||||
confirm = input(
|
||||
"Type 'yes' if you would like to try deleting the test "
|
||||
"database '%s', or 'no' to cancel: " % test_database_name)
|
||||
if autoclobber or confirm == 'yes':
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import sys
|
||||
import time
|
||||
from django.db.backends.creation import BaseDatabaseCreation
|
||||
from django.utils.six.moves import input
|
||||
|
||||
TEST_DATABASE_PREFIX = 'test_'
|
||||
PASSWORD = 'Im_a_lumberjack'
|
||||
|
@ -65,7 +66,7 @@ class DatabaseCreation(BaseDatabaseCreation):
|
|||
except Exception as e:
|
||||
sys.stderr.write("Got an error creating the test database: %s\n" % e)
|
||||
if not autoclobber:
|
||||
confirm = raw_input("It appears the test database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_NAME)
|
||||
confirm = input("It appears the test database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_NAME)
|
||||
if autoclobber or confirm == 'yes':
|
||||
try:
|
||||
if verbosity >= 1:
|
||||
|
@ -87,7 +88,7 @@ class DatabaseCreation(BaseDatabaseCreation):
|
|||
except Exception as e:
|
||||
sys.stderr.write("Got an error creating the test user: %s\n" % e)
|
||||
if not autoclobber:
|
||||
confirm = raw_input("It appears the test user, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_USER)
|
||||
confirm = input("It appears the test user, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_USER)
|
||||
if autoclobber or confirm == 'yes':
|
||||
try:
|
||||
if verbosity >= 1:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import sys
|
||||
from django.db.backends.creation import BaseDatabaseCreation
|
||||
from django.utils.six.moves import input
|
||||
|
||||
class DatabaseCreation(BaseDatabaseCreation):
|
||||
# SQLite doesn't actually support most of these types, but it "does the right
|
||||
|
@ -53,7 +54,7 @@ class DatabaseCreation(BaseDatabaseCreation):
|
|||
print("Destroying old test database '%s'..." % self.connection.alias)
|
||||
if os.access(test_database_name, os.F_OK):
|
||||
if not autoclobber:
|
||||
confirm = raw_input("Type 'yes' if you would like to try deleting the test database '%s', or 'no' to cancel: " % test_database_name)
|
||||
confirm = input("Type 'yes' if you would like to try deleting the test database '%s', or 'no' to cancel: " % test_database_name)
|
||||
if autoclobber or confirm == 'yes':
|
||||
try:
|
||||
os.remove(test_database_name)
|
||||
|
|
|
@ -113,6 +113,7 @@ class _MovedItems(types.ModuleType):
|
|||
_moved_attributes = [
|
||||
MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
|
||||
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
|
||||
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
|
||||
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
|
||||
MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
|
||||
MovedAttribute("reduce", "__builtin__", "functools"),
|
||||
|
|
Loading…
Reference in New Issue