[Checkins] SVN: grokproject/trunk/ assert that the project name is a valid Python identifier
Michael Haubenwallner
michael at d2m.at
Tue May 19 16:16:56 EDT 2009
Log message for revision 100140:
assert that the project name is a valid Python identifier
Changed:
U grokproject/trunk/CHANGES.txt
U grokproject/trunk/grokproject/main.py
-=-
Modified: grokproject/trunk/CHANGES.txt
===================================================================
--- grokproject/trunk/CHANGES.txt 2009-05-19 20:15:33 UTC (rev 100139)
+++ grokproject/trunk/CHANGES.txt 2009-05-19 20:16:56 UTC (rev 100140)
@@ -7,6 +7,10 @@
* Increased z3c.recipe.i18n version to use: 0.5.3 does not emit any
warnings any more when being installed.
+* Assert that project names are valid python identifiers
+ https://bugs.launchpad.net/bugs/223560
+ https://bugs.launchpad.net/bugs/373592
+
1.0a4 (2009-04-17)
------------------
Modified: grokproject/trunk/grokproject/main.py
===================================================================
--- grokproject/trunk/grokproject/main.py 2009-05-19 20:15:33 UTC (rev 100139)
+++ grokproject/trunk/grokproject/main.py 2009-05-19 20:16:56 UTC (rev 100140)
@@ -2,8 +2,10 @@
import pkg_resources
from paste.script import command
import optparse
+import re
from grokproject import GrokProject
+project_name_re=re.compile('[a-zA-Z_][a-zA-Z0-9_]*')
def main():
usage = "usage: %prog [options] PROJECT"
@@ -64,6 +66,16 @@
extra_args.append('zopectl=True')
if options.grokversion:
extra_args.append('grokversion=%s' % options.grokversion)
+
+ # Assert that the project name is a valid Python identifier
+ if not (project_name_re.match(project).group() == project):
+ print
+ print "Error: The chosen project name is not a invalid " \
+ "package name: %s." % project
+ print "Please choose a different project name."
+ sys.exit(1)
+
+ # Create the project
exit_code = runner.run(option_args + ['-t', 'grok', project]
+ extra_args)
sys.exit(exit_code)
More information about the Checkins
mailing list