From e8cae6f96dce803f05a2f696ab968698f1389712 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 16 Aug 2007 19:14:09 +0000 Subject: [PATCH] Fixed bug in django.core.management.base.copy_helper, related to refactoring in [5903] git-svn-id: http://code.djangoproject.com/svn/django/trunk@5907 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management/base.py | 10 +++------- django/core/management/commands/startapp.py | 2 +- django/core/management/commands/startproject.py | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) 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')