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
This commit is contained in:
Adrian Holovaty 2007-08-16 19:14:09 +00:00
parent 3e20e7cc41
commit e8cae6f96d
3 changed files with 5 additions and 9 deletions

View File

@ -65,7 +65,6 @@ class BaseCommand(object):
def handle(self, *args, **options): def handle(self, *args, **options):
raise NotImplementedError() raise NotImplementedError()
class AppCommand(BaseCommand): class AppCommand(BaseCommand):
args = '[appname ...]' args = '[appname ...]'
@ -87,11 +86,10 @@ class AppCommand(BaseCommand):
def handle_app(self, app, **options): def handle_app(self, app, **options):
raise NotImplementedError() raise NotImplementedError()
class LabelCommand(BaseCommand): class LabelCommand(BaseCommand):
args = '[label ...]' args = '[label ...]'
label = 'label' label = 'label'
def handle(self, *labels, **options): def handle(self, *labels, **options):
if not labels: if not labels:
raise CommandError('Enter at least one %s.' % self.label) raise CommandError('Enter at least one %s.' % self.label)
@ -106,7 +104,6 @@ class LabelCommand(BaseCommand):
def handle_label(self, label, **options): def handle_label(self, label, **options):
raise NotImplementedError() raise NotImplementedError()
class NoArgsCommand(BaseCommand): class NoArgsCommand(BaseCommand):
args = '' args = ''
@ -120,8 +117,7 @@ class NoArgsCommand(BaseCommand):
def handle_noargs(self, **options): def handle_noargs(self, **options):
raise NotImplementedError() raise NotImplementedError()
def copy_helper(style, app_or_project, name, directory, other_name=''):
def copy_helper(app_or_project, name, directory, other_name=''):
import django import django
import os import os
import re import re
@ -160,4 +156,4 @@ def copy_helper(app_or_project, name, directory, other_name=''):
try: try:
shutil.copymode(path_old, path_new) shutil.copymode(path_old, path_new)
except OSError: 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))

View File

@ -21,7 +21,7 @@ class Command(LabelCommand):
project_name = os.path.basename(directory) project_name = os.path.basename(directory)
if app_name == project_name: if app_name == project_name:
raise CommandError("You cannot create an app with the same name (%r) as your project." % app_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): class ProjectCommand(Command):
help = "Creates a Django app directory structure for the given app name in this project's directory." help = "Creates a Django app directory structure for the given app name in this project's directory."

View File

@ -23,7 +23,7 @@ class Command(LabelCommand):
if project_name in INVALID_PROJECT_NAMES: 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) 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. # Create a random SECRET_KEY hash, and put it in the main settings.
main_settings_file = os.path.join(directory, project_name, 'settings.py') main_settings_file = os.path.join(directory, project_name, 'settings.py')