Commit 07d899ee authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[c-c newcube] #1192: simpler cubicweb-ctl newcube, and more

* new --layout option, to get 'simple' or 'full' cube
* new --licence option to specify license for the cube
* added README and sobjects.py template (the later only added in full layout)
* fixed python file templates to get proper headers according to the config
parent 395e1ff018ae
......@@ -22,7 +22,8 @@ from logilab.common.clcommands import register_commands, pop_arg
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 @@ class NewCubeCommand(Command):
"""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 @@ class NewCubeCommand(Command):
'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 @@ class NewCubeCommand(Command):
'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
......
Summary
-------
%(longdesc)s
......@@ -7,7 +7,7 @@ distname = '%(distname)s'
numversion = (0, 1, 0)
version = '.'.join(str(num) for num in numversion)
license = 'LCL'
license = '%(license)s'
author = '%(author)s'
author_email = '%(author-email)s'
......@@ -40,6 +40,6 @@ for dname in ('entities', 'views', 'sobjects', 'hooks', 'schema', 'data', 'i18n'
# Note: here, you'll need to add subdirectories if you want
# them to be included in the debian package
__depends__ = {'cubicweb': '>= 3.8.0'}
__depends__ = {'cubicweb': '>= %(version)s'}
__recommends__ = {}
/* template specific CSS */
/* cube-specific CSS */
// This contains template-specific javascript
\ No newline at end of file
// This contains cube-specific javascript
\ No newline at end of file
"""this contains the cube-specific entities' classes
:organization: Logilab
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
"""%(distname)s entity's classes
:organization: %(author)s
:copyright: %(year)s %(author)s
:contact: %(author-web-site)s -- mailto:%(author-email)s
:license: %(long-license)s
"""
"""%(distname)s specific hooks and operations
:organization: %(author)s
:copyright: %(year)s %(author)s
:contact: %(author-web-site)s -- mailto:%(author-email)s
:license: %(long-license)s
"""
# postcreate script. You could setup site properties or a workflow here for example
"""
:organization: Logilab
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
# Example of site property change
#set_property('ui.site-title', "<sitename>")
"""%(distname)s postcreate script, executed at instance creation time or when
the cube is added to an existing instance.
You could setup site properties or a workflow here for example.
:organization: %(author)s
:copyright: %(year)s %(author)s
:contact: %(author-web-site)s -- mailto:%(author-email)s
:license: %(long-license)s
"""
# Example of site property change
#set_property('ui.site-title', "<sitename>")
# Instructions here will be read before reading the schema
"""
:organization: Logilab
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
# You could create your own groups here, like in :
# create_entity('CWGroup', name=u'mygroup')
"""%(distname)s precreate script, executed at instance creation time or when
the cube is added to an existing instance, before the schema is serialized.
This is typically to create groups referenced by the cube'schema.
:organization: %(author)s
:copyright: %(year)s %(author)s
:contact: %(author-web-site)s -- mailto:%(author-email)s
:license: %(long-license)s
"""
# cube's specific schema
"""
:organization: Logilab
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
"""%(distname)s schema
:organization: %(author)s
:copyright: %(year)s %(author)s
:contact: %(author-web-site)s -- mailto:%(author-email)s
:license: %(long-license)s
"""
......@@ -43,6 +43,8 @@ from __pkginfo__ import modname, version, license, description, web, \
if exists('README'):
long_description = file('README').read()
else:
long_description = ''
# import optional features
import __pkginfo__
......
"""%(distname)s repository side views, usually for notification
:organization: %(author)s
:copyright: %(year)s %(author)s
:contact: %(author-web-site)s -- mailto:%(author-email)s
:license: %(long-license)s
"""
"""cube-specific forms/views/actions/components
:organization: Logilab
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
"""%(distname)s views/forms/actions/components for web ui
:organization: %(author)s
:copyright: %(year)s %(author)s
:contact: %(author-web-site)s -- mailto:%(author-email)s
:license: %(long-license)s
"""
......@@ -103,10 +103,9 @@ def show_diffs(appl_file, ref_file, askconfirm=True):
else:
print 'no diff between %s and %s' % (appl_file, ref_file)
SKEL_EXCLUDE = ('*.py[co]', '*.orig', '*~', '*_flymake.py')
def copy_skeleton(skeldir, targetdir, context,
exclude=('*.py[co]', '*.orig', '*~', '*_flymake.py'),
askconfirm=False):
exclude=SKEL_EXCLUDE, askconfirm=False):
import shutil
from fnmatch import fnmatch
skeldir = normpath(skeldir)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment