Fixing a few bugs in pecan create.

This commit is contained in:
Ryan Petrello
2012-03-14 19:15:22 -07:00
parent 0df3ea4ecd
commit 3a5fdc6fc9
3 changed files with 11 additions and 12 deletions

View File

@@ -11,8 +11,8 @@ class CreateCommand(BaseCommand):
"""
arguments = ({
'command': 'destination',
'help': 'the destination to create the new project'
'command': 'project_name',
'help': 'the (package) name of the new project'
}, {
'command': 'template_name',
'help': 'a registered Pecan template',
@@ -22,4 +22,4 @@ class CreateCommand(BaseCommand):
def run(self, args):
super(CreateCommand, self).run(args)
BaseScaffold().copy_to(args.destination)
BaseScaffold().copy_to(args.project_name)

View File

@@ -1,10 +1,12 @@
import sys
import os
import re
import pkg_resources
from string import Template
from pecan.compat import native_, bytes_
DEFAULT_SCAFFOLD = 'base'
_bad_chars_re = re.compile('[^a-zA-Z0-9_]')
class PecanScaffold(object):
@@ -21,15 +23,10 @@ class PecanScaffold(object):
mod = sys.modules[self.__class__.__module__]
return os.path.dirname(mod.__file__)
@property
def variables(self):
return {
'package': self.dest
}
def copy_to(self, dest, **kwargs):
self.dest = dest
copy_dir(self.template_dir, self.dest, self.variables)
output_dir = os.path.abspath(os.path.normpath(dest))
pkg_name = _bad_chars_re.sub('', dest.lower())
copy_dir(self.template_dir, output_dir, {'package': pkg_name})
class BaseScaffold(PecanScaffold):

View File

@@ -132,7 +132,9 @@ class TestTemplateBuilds(unittest.TestCase):
self.poll(proc)
out, _ = proc.communicate('{"model" : model, "conf" : conf, "app" : app}')
out, _ = proc.communicate(
'{"model" : model, "conf" : conf, "app" : app}'
)
assert 'testing123.model' in out
assert 'Config(' in out
assert 'webtest.app.TestApp' in out