|
@@ -1,23 +1,19 @@
|
|
|
|
+import re
|
|
import os
|
|
import os
|
|
from optparse import OptionParser
|
|
from optparse import OptionParser
|
|
from django.core import management
|
|
from django.core import management
|
|
|
|
|
|
|
|
|
|
-def get_misago_project_template():
|
|
|
|
- misago_path = os.path.dirname(os.path.dirname(__file__))
|
|
|
|
- return os.path.join(misago_path, 'project_template')
|
|
|
|
-
|
|
|
|
|
|
+def validate_project_name(parser, project_name):
|
|
|
|
+ if project_name[0].isdigit():
|
|
|
|
+ parser.error("project_name cannot start with digit")
|
|
|
|
|
|
-def start_misago_project():
|
|
|
|
- parser = OptionParser(usage="usage: %prog project_name")
|
|
|
|
- (options, args) = parser.parse_args()
|
|
|
|
-
|
|
|
|
- if len(args) != 1:
|
|
|
|
- parser.error("project_name must be specified")
|
|
|
|
- project_name = args[0]
|
|
|
|
if project_name.startswith("-"):
|
|
if project_name.startswith("-"):
|
|
parser.error("project_name cannot start with '-'")
|
|
parser.error("project_name cannot start with '-'")
|
|
|
|
|
|
|
|
+ if re.search("[^0-9a-zA-Z]", project_name):
|
|
|
|
+ parser.error("project_name cannot contain special characters")
|
|
|
|
+
|
|
# Ensure the given directory name doesn't clash with an existing
|
|
# Ensure the given directory name doesn't clash with an existing
|
|
# Python package/module.
|
|
# Python package/module.
|
|
try:
|
|
try:
|
|
@@ -29,6 +25,23 @@ def start_misago_project():
|
|
"Python module and cannot be used as a project "
|
|
"Python module and cannot be used as a project "
|
|
"name. Please try another name." % project_name)
|
|
"name. Please try another name." % project_name)
|
|
|
|
|
|
|
|
+ return project_name
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def get_misago_project_template():
|
|
|
|
+ misago_path = os.path.dirname(os.path.dirname(__file__))
|
|
|
|
+ return os.path.join(misago_path, 'project_template')
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def start_misago_project():
|
|
|
|
+ parser = OptionParser(usage="usage: %prog project_name")
|
|
|
|
+ (options, args) = parser.parse_args()
|
|
|
|
+
|
|
|
|
+ if len(args) != 1:
|
|
|
|
+ parser.error("project_name must be specified")
|
|
|
|
+
|
|
|
|
+ project_name = validate_project_name(parser, args[0])
|
|
|
|
+
|
|
argv = ['start-misago.py', 'startproject', project_name,
|
|
argv = ['start-misago.py', 'startproject', project_name,
|
|
'--template=%s' % get_misago_project_template()]
|
|
'--template=%s' % get_misago_project_template()]
|
|
|
|
|