[Checkins] SVN: z3c.boiler/trunk/ initial import
Paul Carduner
paulcarduner at gmail.com
Fri Mar 27 04:56:13 EDT 2009
Log message for revision 98397:
initial import
Changed:
A z3c.boiler/trunk/
A z3c.boiler/trunk/bootstrap.py
A z3c.boiler/trunk/buildout.cfg
A z3c.boiler/trunk/setup.py
A z3c.boiler/trunk/src/
A z3c.boiler/trunk/src/z3c/
A z3c.boiler/trunk/src/z3c/__init__.py
A z3c.boiler/trunk/src/z3c/boiler/
A z3c.boiler/trunk/src/z3c/boiler/README.txt
A z3c.boiler/trunk/src/z3c/boiler/__init__.py
A z3c.boiler/trunk/src/z3c/boiler/index.txt
A z3c.boiler/trunk/src/z3c/boiler/interactive.py
A z3c.boiler/trunk/src/z3c/boiler/project-template.xml
A z3c.boiler/trunk/src/z3c/boiler/sample-project.xml
A z3c.boiler/trunk/src/z3c/boiler/script.py
A z3c.boiler/trunk/src/z3c/boiler/tests.py
-=-
Added: z3c.boiler/trunk/bootstrap.py
===================================================================
--- z3c.boiler/trunk/bootstrap.py (rev 0)
+++ z3c.boiler/trunk/bootstrap.py 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: z3c.boiler/trunk/bootstrap.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: z3c.boiler/trunk/buildout.cfg
===================================================================
--- z3c.boiler/trunk/buildout.cfg (rev 0)
+++ z3c.boiler/trunk/buildout.cfg 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,63 @@
+[buildout]
+extends=http://download.zope.org/zope3.4/3.4.0/versions.cfg
+develop = .
+ ../../z3c.feature.core
+ ../../z3c.feature.zope
+ ../../z3c.builder.core
+parts = test
+ coverage-test
+ coverage-report
+ scripts
+ configured-scripts
+ python
+ gtkeggdeps
+ docs
+versions = versions
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.boiler
+ z3c.builder.core [test]
+ z3c.feature.core
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3c.boiler
+ z3c.builder.core [test]
+ z3c.feature.core
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
+
+[scripts]
+recipe = zc.recipe.egg:scripts
+eggs = z3c.boiler
+script = boil
+
+[configured-scripts]
+recipe = zc.recipe.egg:scripts
+eggs = z3c.boiler
+scripts = boil=sample-boil
+arguments = ['-v', '-f', '-o', '.', '-i', 'src/z3c/boiler/sample-project.xml']
+
+[python]
+recipe = zc.recipe.egg
+interpreter = python
+eggs = z3c.boiler
+
+[gtkeggdeps]
+recipe = zc.recipe.egg
+scripts = gtkeggdeps
+eggs = z3c.boiler [deps]
+
+[docs]
+recipe = z3c.recipe.sphinxdoc
+eggs = z3c.boiler [docs]
+doc-eggs = z3c.boiler
+ z3c.builder.core
+ z3c.feature.core
+build-dir = ${buildout:directory}/docs
Added: z3c.boiler/trunk/setup.py
===================================================================
--- z3c.boiler/trunk/setup.py (rev 0)
+++ z3c.boiler/trunk/setup.py 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Setup
+
+$Id$
+"""
+import os
+from setuptools import setup, find_packages
+
+setup (
+ name='z3c.boiler',
+ version='0.1.0dev',
+ author = "Paul Carduner, Stephan Richter, and hopefully others...",
+ author_email = "zope-dev at zope.org",
+ description = "A utility to help jump start Zope 3 projects",
+ license = "ZPL 2.1",
+ keywords = "zope3 project builder boiler",
+ url = 'http://pypi.python.org/pypi/z3c.boiler',
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['z3c'],
+ extras_require = dict(
+ test = [
+ 'zope.testing',
+ 'z3c.coverage',
+ ],
+ docs = ['Sphinx',
+ 'z3c.recipe.sphinxdoc'],
+ deps = ['gtkeggdeps'],
+ ),
+ install_requires = [
+ 'setuptools',
+ 'zc.buildout',
+ 'z3c.builder.core',
+ 'z3c.feature.core',
+ 'z3c.feature.zope',
+ ],
+ zip_safe = False,
+ entry_points = """
+ [console_scripts]
+ boil = z3c.boiler.script:main
+ """,
+ )
Property changes on: z3c.boiler/trunk/setup.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: z3c.boiler/trunk/src/z3c/__init__.py
===================================================================
--- z3c.boiler/trunk/src/z3c/__init__.py (rev 0)
+++ z3c.boiler/trunk/src/z3c/__init__.py 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,7 @@
+try:
+ # Declare this a namespace package if pkg_resources is available.
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ pass
+
Property changes on: z3c.boiler/trunk/src/z3c/__init__.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: z3c.boiler/trunk/src/z3c/boiler/README.txt
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/README.txt (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/README.txt 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,232 @@
+======================================
+ZBoiler - A Quick Way to Boil Projects
+======================================
+
+The ZBoiler package provides a small script to generate the boilerplate of a
+project from a simple, high-level feature XML file. An example of such a
+configuration file is `sample-project.xml`.
+
+ >>> from z3c.boiler import script
+
+ >>> def boil(args, showLog=False):
+ ... try:
+ ... script.main(args)
+ ... except SystemExit, err:
+ ... print 'Exit Code: %i' % err.code
+ ... else:
+ ... print 'Error: No proper exit.'
+
+Let's generate the project using the script. We need to specify the
+configuration file and a target directory.
+
+ >>> import os
+ >>> featureFile = os.path.join(
+ ... os.path.dirname(script.__file__), 'sample-project.xml')
+
+ >>> boil(['-i', featureFile, '-o', buildPath])
+ INFO - Creating directory .../z3c.sampleproject
+ INFO - Creating file .../z3c.sampleproject/bootstrap.py
+ INFO - Creating file .../z3c.sampleproject/setup.py
+ INFO - Creating file .../z3c.sampleproject/buildout.cfg
+ INFO - Creating directory .../z3c.sampleproject/src
+ INFO - Creating directory .../z3c.sampleproject/src/z3c
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/application.zcml
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject/browser
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/configure.zcml
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/message.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/configure.zcml
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/interfaces.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/index.txt
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject/tests
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/tests/test_doc.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/tests/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/README.txt
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/message.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/__init__.py
+ INFO - Creating file .../z3c.sampleproject/ZBOILER.txt
+ INFO - Build finished
+ Exit Code: 0
+
+Let's now have a look at the generated directory:
+
+ >>> ls(buildPath)
+ z3c.sampleproject/
+ ZBOILER.txt
+ bootstrap.py
+ buildout.cfg
+ setup.py
+ src/
+ z3c/
+ __init__.py
+ sampleproject/
+ README.txt
+ __init__.py
+ application.zcml
+ configure.zcml
+ index.txt
+ interfaces.py
+ message.py
+ browser/
+ __init__.py
+ configure.zcml
+ message.pytests/
+ __init__.py
+ test_doc.py
+
+When we try to regenerate the project again, we get a failure, since the
+directory already exists:
+
+ >>> boil(['-i', featureFile, '-o', buildPath])
+ CRITICAL - Failed building package because file .../z3c.sampleproject
+ already exists. Use --force to overwrite it.
+ Exit Code: 1
+
+We can, however, force the directory to be overwritten as the message
+mentions:
+
+ >>> boil(['-f', '-i', featureFile, '-o', buildPath])
+ INFO - Creating directory .../z3c.sampleproject
+ INFO - Creating file .../z3c.sampleproject/bootstrap.py
+ INFO - Creating file .../z3c.sampleproject/setup.py
+ INFO - Creating file .../z3c.sampleproject/buildout.cfg
+ INFO - Creating directory .../z3c.sampleproject/src
+ INFO - Creating directory .../z3c.sampleproject/src/z3c
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/application.zcml
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject/browser
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/configure.zcml
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/message.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/configure.zcml
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/interfaces.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/index.txt
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject/tests
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/tests/test_doc.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/tests/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/README.txt
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/message.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/__init__.py
+ INFO - Creating file .../z3c.sampleproject/ZBOILER.txt
+ INFO - Build finished
+ Exit Code: 0
+
+If we want less information, we can simply tell the script to be quiet:
+
+ >>> boil(['-q', '-f', '-i', featureFile, '-o', buildPath])
+ Exit Code: 0
+
+Fatal messages are still displayed:
+
+ >>> boil(['-q', '-i', featureFile, '-o', buildPath])
+ CRITICAL - Failed building package because file .../z3c.sampleproject
+ already exists. Use --force to overwrite it.
+ Exit Code: 1
+
+We can also ask for more information:
+
+ >>> boil(['-v', '-f', '-i', featureFile, '-o', buildPath])
+ DEBUG - Updating <SimpleFileBuilder u'bootstrap.py'>
+ DEBUG - Updating <PartBuilder u'versions'>
+ DEBUG - Updating <PartBuilder u'zope3'>
+ DEBUG - Updating <PartBuilder u'z3c.sampleproject-app'>
+ DEBUG - Updating <PartBuilder u'z3c.sampleproject'>
+ DEBUG - Updating <PartBuilder u'database'>
+ DEBUG - Updating <PartBuilder u'docs'>
+ DEBUG - Updating <PartBuilder u'python'>
+ DEBUG - Updating <PartBuilder u'test'>
+ DEBUG - Updating <PartBuilder u'coverage-test'>
+ DEBUG - Updating <PartBuilder u'coverage-report'>
+ DEBUG - Updating <PackageBuilder u'z3c'>
+ DEBUG - Updating <PackageBuilder u'sampleproject'>
+ DEBUG - Updating <PackageBuilder u'browser'>
+ DEBUG - Updating <ModuleBuilder u'message.py'>
+ DEBUG - Updating <ModuleBuilder u'interfaces.py'>
+ DEBUG - Updating <PackageBuilder u'tests'>
+ DEBUG - Updating <SimpleFileBuilder u'test_doc.py'>
+ DEBUG - Updating <SimpleFileBuilder u'README.txt'>
+ DEBUG - Updating <ModuleBuilder u'message.py'>
+ DEBUG - Updating <FeatureDocBuilder u'ZBOILER.txt'>
+ INFO - Creating directory .../z3c.sampleproject
+ INFO - Creating file .../z3c.sampleproject/bootstrap.py
+ INFO - Creating file .../z3c.sampleproject/setup.py
+ INFO - Creating file .../z3c.sampleproject/buildout.cfg
+ INFO - Creating directory .../z3c.sampleproject/src
+ INFO - Creating directory .../z3c.sampleproject/src/z3c
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/application.zcml
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject/browser
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/configure.zcml
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/message.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/browser/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/configure.zcml
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/interfaces.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/index.txt
+ INFO - Creating directory .../z3c.sampleproject/src/z3c/sampleproject/tests
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/tests/test_doc.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/tests/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/README.txt
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/message.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/sampleproject/__init__.py
+ INFO - Creating file .../z3c.sampleproject/src/z3c/__init__.py
+ INFO - Creating file .../z3c.sampleproject/ZBOILER.txt
+ INFO - Build finished
+ Exit Code: 0
+
+It is also possible to use a built in project template as a basis for
+a new project. To see an available list of built in templates, we use
+the --list option.
+
+ >>> boil(['--list'])
+ Available Templates:
+ <BLANKLINE>
+ zope-project "Zope 3 Web Application"
+ Includes all the features you would want for a Zope 3 Web Application.
+ command-line "Command Line Program"
+ Includes all the features you would want for a command line program.
+ python-package "Python Package"
+ Just a simple python package with few bells and whistles.
+ Exit Code: 0
+
+If we try to use a template that does not exist, then we are told to
+use --list:
+
+ >>> boil(['-t','foobar'])
+ Could not find the template "foobar".
+ Use --list to see available templates.
+ Exit Code: 1
+
+
+Last but not least, we also have some help for the `boil` script:
+
+ >>> boil(['-h'])
+ Usage: test [options]
+ <BLANKLINE>
+ Options:
+ -h, --help show this help message and exit
+ -i FILE, --input-file=FILE
+ The file containing the XML definition of the project.
+ -t TEMPLATE, --template=TEMPLATE
+ A project template. Use --list to see available
+ templates
+ -l, --list Show a list of available templates for use with
+ --template
+ -k, --interactive When specified, runs in interactive mode prompting you
+ to enter missing values.
+ -o DIR, --output-dir=DIR
+ The directory where project files should be generated.
+ -q, --quiet When specified, no messages are displayed.
+ -v, --verbose When specified, debug information is created.
+ -f, --force Force the package to be generated even overwriting any
+ existing files.
+ Exit Code: 0
+
+When no arguments are specified, help is also shown:
+
+ >>> boil([])
+ Usage: test [options]
+ ...
+ Exit Code: 0
Property changes on: z3c.boiler/trunk/src/z3c/boiler/README.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: z3c.boiler/trunk/src/z3c/boiler/__init__.py
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/__init__.py (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/__init__.py 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1 @@
+# Make a package.
Property changes on: z3c.boiler/trunk/src/z3c/boiler/__init__.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: z3c.boiler/trunk/src/z3c/boiler/index.txt
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/index.txt (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/index.txt 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,17 @@
+=====================
+ZBoiler Documentation
+=====================
+
+See also the Builder_ and Feature_ documentation.
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ README
+
+
+.. _Builder: ../z3c.builder/index.html
+
+.. _Feature: ../z3c.feature.core/index.html
Property changes on: z3c.boiler/trunk/src/z3c/boiler/index.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: z3c.boiler/trunk/src/z3c/boiler/interactive.py
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/interactive.py (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/interactive.py 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,107 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Interactive CLI
+
+$Id$
+"""
+import logging
+from z3c.feature.core import xml, template
+from z3c.feature.core.xml import etree
+from z3c.builder.core import project, base
+from zope.schema import List
+
+def prompt(field):
+ promptText = field.title
+ if field.default:
+ promptText += " [%s]" % field.default
+ if field.description:
+ promptText += " (? for help)"
+ promptText += ": "
+
+ nonSubmitValues = {}
+ if field.description:
+ nonSubmitValues['?'] = field.description
+
+ def getResponse(value):
+ while value in nonSubmitValues.keys():
+ print nonSubmitValues[value]
+ value = raw_input(promptText)
+ return unicode(value)
+
+ if hasattr(field, 'fromUnicode'):
+ if field.required and not field.default:
+ nonSubmitValues[""] = "Sorry, but this field is required."
+
+ value = getResponse(raw_input(promptText))
+ if value == "" and field.default:
+ print "using default value: %s" % field.default
+ value = field.default
+ if value != "":
+ value = field.fromUnicode(value)
+ elif isinstance(field, List):
+ valueList = []
+ value = None
+ while value != "":
+ value = getResponse(raw_input(promptText))
+ if value:
+ valueList.append(value)
+ value = valueList
+ else:
+ base.logger.warn("Not sure how to convert field: %s" % field)
+ value = unicode(value)
+ return value
+
+def xmlToProject(node):
+ originalNode = node
+ node = xml.getNode(node)
+ name = raw_input("Enter the name for this project: ").strip()
+ while name == "":
+ print "You must provide a name for your project."
+ name = raw_input("Enter the name for this project: ").strip()
+ node.set('name',name)
+
+ # fill in missing xml by prompting
+ for featureNode in node.xpath('//feature'):
+ factory = xml.getFeatureFactory(featureNode)
+ data = xml.extractData(featureNode, factory.iface, convert=False)
+ fieldNames = [n for n in factory.iface if data.get(n) == '?']
+ if fieldNames:
+ print ""
+ header = "Options for: "+featureNode.get("type")
+ print header
+ print "-"*len(header)
+ for fieldName in fieldNames:
+ fieldValue = prompt(factory.iface[fieldName])
+ fieldNode = featureNode.xpath('./%s' % fieldName.replace('_','-'))[0]
+ if isinstance(fieldValue, unicode):
+ fieldNode.text = fieldValue
+ elif isinstance(fieldValue, list):
+ fieldNode.text = None
+ for item in fieldValue:
+ itemNode = etree.SubElement(fieldNode, "item")
+ itemNode.text = item
+ print
+ print "Finished creating xml definition."
+ print
+ if raw_input("Do you want to see the generated xml definition? (y/[n]): ") == 'y':
+ print etree.tostring(node, pretty_print=True)
+ if raw_input("Does this look right? ([y]/n): ") == 'n':
+ print
+ raw_input("Ok, we'll start over.")
+ print
+ print '-'*78
+ print
+ return xmlToProject(originalNode)
+ return xml.xmlToProject(node)
+
Property changes on: z3c.boiler/trunk/src/z3c/boiler/interactive.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: z3c.boiler/trunk/src/z3c/boiler/project-template.xml
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/project-template.xml (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/project-template.xml 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,20 @@
+<project name="?">
+
+ <feature type="z3c.feature.core:meta-data">
+ <license>ZPL</license>
+ <version>?</version>
+ <author>?</author>
+ <author-email>?</author-email>
+ <description>?</description>
+ <keywords>?</keywords>
+ </feature>
+
+ <feature type="z3c.feature.core:python-interpreter">
+ <executableName>?</executableName>
+ </feature>
+
+ <feature type="z3c.feature.core:unit-testing" />
+ <feature type="z3c.feature.core:script" />
+ <feature type="z3c.feature.core:documentation" />
+
+</project>
Property changes on: z3c.boiler/trunk/src/z3c/boiler/project-template.xml
___________________________________________________________________
Added: svn:eol-style
+ native
Added: z3c.boiler/trunk/src/z3c/boiler/sample-project.xml
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/sample-project.xml (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/sample-project.xml 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,37 @@
+<project name="z3c.sampleproject">
+
+ <feature type="z3c.feature.core:meta-data">
+ <license>ZPL</license>
+ <version>0.1.0</version>
+ <author>Paul Carduner and Stephan Richter</author>
+ <author-email>zope-dev at zope.org</author-email>
+ <description>A utility to help jump start Zope 3 projects</description>
+ <license>ZPL 2.1</license>
+ <keywords><item>zope3</item><item>project</item><item>builder</item></keywords>
+ <url>http://pypi.python.org/pypi/z3c.builder</url>
+ <namespace-packages><item>z3c</item></namespace-packages>
+ <feature type="z3c.feature.core:comment-header-ZPL">
+ <year>2009</year>
+ </feature>
+
+ </feature>
+
+ <feature type="z3c.feature.core:python-interpreter">
+ <executableName>py</executableName>
+ </feature>
+
+ <feature type="z3c.feature.core:unit-testing" />
+ <feature type="z3c.feature.core:documentation" />
+
+ <feature type="z3c.feature.zope:zope-project" />
+ <feature type="z3c.feature.zope:zope-skin" />
+ <feature type="z3c.feature.zope:content-type">
+ <className>Message</className>
+ <fields>
+ <field name="receiver" type="zope.schema.TextLine"/>
+ <field name="sender" type="zope.schema.TextLine"/>
+ <field name="message" type="zope.schema.Text"/>
+ </fields>
+ </feature>
+
+</project>
Property changes on: z3c.boiler/trunk/src/z3c/boiler/sample-project.xml
___________________________________________________________________
Added: svn:eol-style
+ native
Added: z3c.boiler/trunk/src/z3c/boiler/script.py
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/script.py (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/script.py 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,154 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Command Line Interface
+
+$Id$
+"""
+import logging
+import optparse
+import os
+import sys
+from z3c.feature.core import xml, template
+from z3c.feature.core.interfaces import IFileBasedTemplateProvider
+from z3c.feature.core.interfaces import MissingFeatureDependencyError
+from z3c.builder.core import base, interfaces
+from z3c.boiler import interactive
+
+parser = optparse.OptionParser()
+parser.add_option(
+ "-i", "--input-file", action="store",
+ dest="inputFile", metavar="FILE",
+ help="The file containing the XML definition of the project.")
+
+parser.add_option(
+ "-t", "--template", action="store",
+ dest="template",
+ help="A project template. Use --list to see available templates")
+
+parser.add_option(
+ "-l", "--list", action="store_true",
+ dest="listTemplates",
+ help="Show a list of available templates for use with --template")
+
+parser.add_option(
+ "-k", "--interactive", action="store_true",
+ dest="interactive", default=False,
+ help=("When specified, runs in interactive mode "
+ "prompting you to enter missing values."))
+
+parser.add_option(
+ "-o","--output-dir", action="store",
+ dest="outputDirectory", metavar="DIR",
+ default=u".",
+ help="The directory where project files should be generated.")
+
+parser.add_option(
+ "-q","--quiet", action="store_true",
+ dest="quiet", default=False,
+ help="When specified, no messages are displayed.")
+
+parser.add_option(
+ "-v","--verbose", action="store_true",
+ dest="verbose", default=False,
+ help="When specified, debug information is created.")
+
+
+parser.add_option(
+ "-f","--force", action="store_true",
+ dest="force",
+ help=("Force the package to be generated "
+ "even overwriting any existing files."))
+
+
+def main(args=None):
+ # Make sure we get the arguments.
+ if args is None:
+ args = sys.argv[1:]
+ if not args:
+ args = ['-h']
+
+ # Set up logger handler
+ handler = logging.StreamHandler(sys.stdout)
+ handler.setFormatter(base.formatter)
+ base.logger.addHandler(handler)
+
+ # Parse arguments
+ options, args = parser.parse_args(args)
+
+ if options.listTemplates:
+ print "Available Templates:"
+ print
+ temps = [(name, temp) for name, temp in template.getTemplateList().items()
+ if IFileBasedTemplateProvider.providedBy(temp)]
+ nameSize = max([len(name) for name, temp in temps])
+ for name, temp in temps:
+ nameLine = ' %s' % name
+ nameLine += ' '*(nameSize-len(name))
+ nameLine += ' "%s"' % temp.title
+ print nameLine
+ print nameSize*' '+' '+temp.description.strip().replace('\n','\n ')
+ sys.exit(0)
+
+ if not options.inputFile and not options.template:
+ print "You must specify an input file or template"
+ args = ['-h']
+ parser.parse_args(args)
+ elif not options.inputFile:
+ try:
+ inputFile = template.getTemplate(options.template).filename
+ except KeyError:
+ print "Could not find the template \"%s\"." % options.template
+ print "Use --list to see available templates."
+ sys.exit(1)
+ else:
+ inputFile = options.inputFile
+
+ base.logger.setLevel(logging.INFO)
+ if options.verbose:
+ base.logger.setLevel(logging.DEBUG)
+ if options.quiet:
+ base.logger.setLevel(logging.FATAL)
+
+ status = 0
+ # Parse the project XML file into builder components.
+ if options.interactive:
+ try:
+ builder = interactive.xmlToProject(open(inputFile, 'r'))
+ except KeyboardInterrupt:
+ print "\nquitting"
+ sys.exit(status)
+ else:
+ try:
+ builder = xml.xmlToProject(open(inputFile, 'r'))
+ except MissingFeatureDependencyError, e:
+ base.logger.fatal("An error occured:\n %r" % e)
+ sys.exit(1)
+
+ # Write the project using the builders.
+ try:
+ builder.update()
+ builder.write(options.outputDirectory, options.force)
+ except interfaces.FileExistsException, e:
+ base.logger.fatal("Failed building package because file %s "
+ "already exists. Use --force to overwrite "
+ "it." % e.filename)
+ status = 1
+ else:
+ base.logger.info("Build finished")
+
+ # Remove the handler again.
+ base.logger.removeHandler(handler)
+
+ # Exit cleanly.
+ sys.exit(status)
Property changes on: z3c.boiler/trunk/src/z3c/boiler/script.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: z3c.boiler/trunk/src/z3c/boiler/tests.py
===================================================================
--- z3c.boiler/trunk/src/z3c/boiler/tests.py (rev 0)
+++ z3c.boiler/trunk/src/z3c/boiler/tests.py 2009-03-27 08:56:13 UTC (rev 98397)
@@ -0,0 +1,41 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test Setup.
+
+$Id$
+"""
+import cStringIO
+import re
+import unittest
+from z3c.builder.core import testing
+from zope.testing import renormalizing, doctest
+
+def test_suite():
+ checker = renormalizing.RENormalizing([
+ (re.compile(
+ '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{6}'),
+ '<DATETIME>'),
+ (re.compile(
+ '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'),
+ '<UUID>'),
+ ])
+
+ return unittest.TestSuite((
+
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=testing.buildSetUp, tearDown=testing.buildTearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ checker=checker),
+ ))
Property changes on: z3c.boiler/trunk/src/z3c/boiler/tests.py
___________________________________________________________________
Added: svn:keywords
+ Id
More information about the Checkins
mailing list