Fixing a few bugs in pecan create.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user