diff --git a/django/core/management/base.py b/django/core/management/base.py index 4041787bc3..3b88234a94 100644 --- a/django/core/management/base.py +++ b/django/core/management/base.py @@ -65,7 +65,6 @@ class BaseCommand(object): def handle(self, *args, **options): raise NotImplementedError() - class AppCommand(BaseCommand): args = '[appname ...]' @@ -87,11 +86,10 @@ class AppCommand(BaseCommand): def handle_app(self, app, **options): raise NotImplementedError() - class LabelCommand(BaseCommand): args = '[label ...]' label = 'label' - + def handle(self, *labels, **options): if not labels: raise CommandError('Enter at least one %s.' % self.label) @@ -106,7 +104,6 @@ class LabelCommand(BaseCommand): def handle_label(self, label, **options): raise NotImplementedError() - class NoArgsCommand(BaseCommand): args = '' @@ -120,8 +117,7 @@ class NoArgsCommand(BaseCommand): def handle_noargs(self, **options): raise NotImplementedError() - -def copy_helper(app_or_project, name, directory, other_name=''): +def copy_helper(style, app_or_project, name, directory, other_name=''): import django import os import re @@ -160,4 +156,4 @@ def copy_helper(app_or_project, name, directory, other_name=''): try: shutil.copymode(path_old, path_new) except OSError: - sys.stderr.write(self.style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new)) + sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new)) diff --git a/django/core/management/commands/startapp.py b/django/core/management/commands/startapp.py index acc965cf44..1da2776cf5 100644 --- a/django/core/management/commands/startapp.py +++ b/django/core/management/commands/startapp.py @@ -21,7 +21,7 @@ class Command(LabelCommand): project_name = os.path.basename(directory) if app_name == project_name: raise CommandError("You cannot create an app with the same name (%r) as your project." % app_name) - copy_helper('app', app_name, directory, parent_dir) + copy_helper(self.style, 'app', app_name, directory, parent_dir) class ProjectCommand(Command): help = "Creates a Django app directory structure for the given app name in this project's directory." diff --git a/django/core/management/commands/startproject.py b/django/core/management/commands/startproject.py index 8394117b70..0d9e4bd381 100644 --- a/django/core/management/commands/startproject.py +++ b/django/core/management/commands/startproject.py @@ -23,7 +23,7 @@ class Command(LabelCommand): if project_name in INVALID_PROJECT_NAMES: raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." % project_name) - copy_helper('project', project_name, directory) + copy_helper(self.style, 'project', project_name, directory) # Create a random SECRET_KEY hash, and put it in the main settings. main_settings_file = os.path.join(directory, project_name, 'settings.py')