Fixed #17099 -- Removed an out-of-date warning and some unused code, now that startapp doesn't require creating app inside project. Thanks ptone for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17030 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
965c5d7cce
commit
d89be53d95
|
@ -357,7 +357,7 @@ class NoArgsCommand(BaseCommand):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def copy_helper(style, app_or_project, name, directory, other_name=''):
|
||||
def copy_helper(style, app_or_project, name, directory):
|
||||
"""
|
||||
Copies either a Django application layout template or a Django project
|
||||
layout template into the specified directory.
|
||||
|
@ -367,11 +367,9 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
|
|||
# app_or_project -- The string 'app' or 'project'.
|
||||
# name -- The name of the application or project.
|
||||
# directory -- The directory to which the layout template should be copied.
|
||||
# other_name -- When copying an application layout, this should be the name
|
||||
# of the project.
|
||||
import re
|
||||
import shutil
|
||||
other = {'project': 'app', 'app': 'project'}[app_or_project]
|
||||
|
||||
if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory name.
|
||||
# Provide a smart error message, depending on the error.
|
||||
if not re.search(r'^[_a-zA-Z]', name):
|
||||
|
@ -406,7 +404,7 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
|
|||
path_new = os.path.join(top_dir, relative_dir, f.replace('%s_name' % app_or_project, name))
|
||||
fp_old = open(path_old, 'r')
|
||||
fp_new = open(path_new, 'w')
|
||||
fp_new.write(fp_old.read().replace('{{ %s_name }}' % app_or_project, name).replace('{{ %s_name }}' % other, other_name))
|
||||
fp_new.write(fp_old.read().replace('{{ %s_name }}' % app_or_project, name))
|
||||
fp_old.close()
|
||||
fp_new.close()
|
||||
try:
|
||||
|
|
|
@ -17,14 +17,6 @@ class Command(LabelCommand):
|
|||
if directory is None:
|
||||
directory = os.getcwd()
|
||||
|
||||
# Determine the project_name by using the basename of directory,
|
||||
# which should be the full path of the project directory (or the
|
||||
# current directory if no directory was passed).
|
||||
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)
|
||||
|
||||
# Check that the app_name cannot be imported.
|
||||
try:
|
||||
import_module(app_name)
|
||||
|
@ -33,15 +25,4 @@ class Command(LabelCommand):
|
|||
else:
|
||||
raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name." % app_name)
|
||||
|
||||
copy_helper(self.style, 'app', app_name, directory, project_name)
|
||||
|
||||
class ProjectCommand(Command):
|
||||
help = ("Creates a Django app directory structure for the given app name"
|
||||
" in this project's directory.")
|
||||
|
||||
def __init__(self, project_directory):
|
||||
super(ProjectCommand, self).__init__()
|
||||
self.project_directory = project_directory
|
||||
|
||||
def handle_label(self, app_name, **options):
|
||||
super(ProjectCommand, self).handle_label(app_name, self.project_directory, **options)
|
||||
copy_helper(self.style, 'app', app_name, directory)
|
||||
|
|
Loading…
Reference in New Issue