--- a/web/lib/django/core/management/base.py Wed May 19 17:43:59 2010 +0200
+++ b/web/lib/django/core/management/base.py Tue May 25 02:43:45 2010 +0200
@@ -11,11 +11,7 @@
import django
from django.core.exceptions import ImproperlyConfigured
from django.core.management.color import color_style
-
-try:
- set
-except NameError:
- from sets import Set as set # For Python 2.3
+from django.utils.encoding import smart_str
class CommandError(Exception):
"""
@@ -28,7 +24,7 @@
result, raising this exception (with a sensible description of the
error) is the preferred way to indicate that something has gone
wrong in the execution of a command.
-
+
"""
pass
@@ -37,7 +33,7 @@
Include any default options that all commands should accept here
so that ManagementUtility can handle them before searching for
user commands.
-
+
"""
if options.settings:
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
@@ -83,7 +79,7 @@
specialized methods as needed.
Several attributes affect behavior at various steps along the way:
-
+
``args``
A string listing the arguments accepted by the command,
suitable for use in help messages; e.g., a command which takes
@@ -117,7 +113,7 @@
rather than all applications' models, call
``self.validate(app)`` from ``handle()``, where ``app`` is the
application's Python module.
-
+
"""
# Metadata about this command.
option_list = (
@@ -147,7 +143,7 @@
Return the Django version, which should be correct for all
built-in Django commands. User-supplied commands should
override this method.
-
+
"""
return django.get_version()
@@ -155,7 +151,7 @@
"""
Return a brief description of how to use this command, by
default from the attribute ``self.help``.
-
+
"""
usage = '%%prog %s [options] %s' % (subcommand, self.args)
if self.help:
@@ -167,7 +163,7 @@
"""
Create and return the ``OptionParser`` which will be used to
parse the arguments to this command.
-
+
"""
return OptionParser(prog=prog_name,
usage=self.usage(subcommand),
@@ -178,7 +174,7 @@
"""
Print the help message for this command, derived from
``self.usage()``.
-
+
"""
parser = self.create_parser(prog_name, subcommand)
parser.print_help()
@@ -187,7 +183,7 @@
"""
Set up any environment changes requested (e.g., Python path
and Django settings), then run this command.
-
+
"""
parser = self.create_parser(argv[0], argv[1])
options, args = parser.parse_args(argv[2:])
@@ -201,7 +197,7 @@
``self.requires_model_validation``). If the command raises a
``CommandError``, intercept it and print it sensibly to
stderr.
-
+
"""
# Switch to English, because django-admin.py creates database content
# like permissions, and those shouldn't contain any translations.
@@ -214,7 +210,7 @@
except ImportError, e:
# If settings should be available, but aren't,
# raise the error and quit.
- sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e)))
+ sys.stderr.write(smart_str(self.style.ERROR('Error: %s\n' % e)))
sys.exit(1)
try:
if self.requires_model_validation:
@@ -230,15 +226,15 @@
if self.output_transaction:
print self.style.SQL_KEYWORD("COMMIT;")
except CommandError, e:
- sys.stderr.write(self.style.ERROR(str('Error: %s\n' % e)))
+ sys.stderr.write(smart_str(self.style.ERROR('Error: %s\n' % e)))
sys.exit(1)
def validate(self, app=None, display_num_errors=False):
"""
Validates the given app, raising CommandError for any errors.
-
+
If app is None, then this will validate all installed apps.
-
+
"""
from django.core.management.validation import get_validation_errors
try:
@@ -258,7 +254,7 @@
"""
The actual logic of the command. Subclasses must implement
this method.
-
+
"""
raise NotImplementedError()
@@ -269,7 +265,7 @@
Rather than implementing ``handle()``, subclasses must implement
``handle_app()``, which will be called once for each application.
-
+
"""
args = '<appname appname ...>'
@@ -293,7 +289,7 @@
Perform the command's actions for ``app``, which will be the
Python module corresponding to an application name given on
the command line.
-
+
"""
raise NotImplementedError()
@@ -308,7 +304,7 @@
If the arguments should be names of installed applications, use
``AppCommand`` instead.
-
+
"""
args = '<label label ...>'
label = 'label'
@@ -328,7 +324,7 @@
"""
Perform the command's actions for ``label``, which will be the
string as given on the command line.
-
+
"""
raise NotImplementedError()
@@ -341,7 +337,7 @@
no arguments are passed to the command.
Attempting to pass arguments will raise ``CommandError``.
-
+
"""
args = ''
@@ -353,7 +349,7 @@
def handle_noargs(self, **options):
"""
Perform this command's actions.
-
+
"""
raise NotImplementedError()
@@ -419,7 +415,7 @@
"""
Make sure that the file is writeable. Useful if our source is
read-only.
-
+
"""
import stat
if sys.platform.startswith('java'):