--- a/devtools/devctl.py Wed Apr 07 14:42:55 2010 +0200
+++ b/devtools/devctl.py Thu Apr 08 11:04:17 2010 +0200
@@ -22,7 +22,8 @@
from cubicweb.__pkginfo__ import version as cubicwebversion
from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage
-from cubicweb.toolsutils import Command, copy_skeleton, underline_title
+from cubicweb.toolsutils import (SKEL_EXCLUDE, Command,
+ copy_skeleton, underline_title)
from cubicweb.web.webconfig import WebConfiguration
from cubicweb.server.serverconfig import ServerConfiguration
@@ -440,12 +441,19 @@
"""Create a new cube.
<cubename>
- the name of the new cube
+ the name of the new cube. It should be a valid python module name.
"""
name = 'newcube'
arguments = '<cubename>'
options = (
+ ("layout",
+ {'short': 'L', 'type' : 'choice', 'metavar': '<cube layout>',
+ 'default': 'simple', 'choices': ('simple', 'full'),
+ 'help': 'cube layout. You\'ll get a minimal cube with the "simple" \
+layout, and a full featured cube with "full" layout.',
+ }
+ ),
("directory",
{'short': 'd', 'type' : 'string', 'metavar': '<cubes directory>',
'help': 'directory where the new cube should be created',
@@ -475,14 +483,28 @@
'help': 'cube author\'s web site',
}
),
+ ("license",
+ {'short': 'l', 'type' : 'choice', 'metavar': '<license>',
+ 'default': 'LGPL', 'choices': ('GPL', 'LGPL', ''),
+ 'help': 'cube license',
+ }
+ ),
)
+ LICENSES = {
+ 'LGPL': 'GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses',
+ 'GPL': 'GNU General Public License, v2.1 - http://www.gnu.org/licenses',
+ '': 'closed source'
+ }
def run(self, args):
+ import re
from logilab.common.shellutils import ASK
if len(args) != 1:
raise BadCommandUsage("exactly one argument (cube name) is expected")
- cubename, = args
+ cubename = args[0]
+ if not re.match('[_A-Za-z][_A-Za-z0-9]*$', cubename):
+ raise BadCommandUsage("cube name should be a valid python module name")
verbose = self.get('verbose')
cubesdir = self.get('directory')
if not cubesdir:
@@ -533,8 +555,14 @@
'author': self['author'],
'author-email': self['author-email'],
'author-web-site': self['author-web-site'],
+ 'license': self['license'],
+ 'long-license': self.LICENSES[self['license']],
}
- copy_skeleton(skeldir, cubedir, context)
+ exclude = SKEL_EXCLUDE
+ if self['layout'] == 'simple':
+ exclude += ('sobjects.py*', 'precreate.py*', 'realdb_test*',
+ 'cubes.*', 'external_resources*')
+ copy_skeleton(skeldir, cubedir, context, exclude=exclude)
def _ask_for_dependancies(self):
from logilab.common.shellutils import ASK