[Checkins] SVN: grokproject/trunk/ simplify version specification and *.cfg file lookup
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Mon Oct 25 02:26:55 EDT 2010
Log message for revision 117829:
simplify version specification and *.cfg file lookup
Changed:
U grokproject/trunk/grokproject/main.py
U grokproject/trunk/grokproject/templates.py
U grokproject/trunk/tests_paste.txt
-=-
Modified: grokproject/trunk/grokproject/main.py
===================================================================
--- grokproject/trunk/grokproject/main.py 2010-10-23 23:14:42 UTC (rev 117828)
+++ grokproject/trunk/grokproject/main.py 2010-10-25 06:26:54 UTC (rev 117829)
@@ -10,18 +10,22 @@
def main():
usage = "usage: %prog [options] PROJECT"
parser = optparse.OptionParser(usage=usage)
- parser.add_option('--svn-repository', dest="repos", default=None,
- help="Import project to given repository location (this "
- "will also create the standard trunk/ tags/ branches/ "
- "hierarchy).")
- parser.add_option('--grokversion', dest="grokversion", default=None,
- help="Specify the Grok version to use. GROKVERSION is "
- "a string like 0.14.1, 1.0a1 or similar. If not given, "
- "the latest version found on the grok website is used.")
- parser.add_option('-v', '--verbose', action="store_true", dest="verbose",
- default=False, help="Be verbose.")
- parser.add_option('--version', action="store_true", dest="version",
- default=False, help="Show grokproject version.")
+ parser.add_option(
+ '--svn-repository', dest="repos", default=None, help=(
+ "Import project to given repository location (this "
+ "will also create the standard trunk/ tags/ branches/ "
+ "hierarchy)."))
+ parser.add_option(
+ '--version-url', dest="version_url", default=None, help=(
+ "Specify the URL to a buildout file defining package versions. "
+ "If not given, the latest version info found on the grok website is "
+ "used."))
+ parser.add_option(
+ '-v', '--verbose', action="store_true", dest="verbose", default=False,
+ help="Be verbose.")
+ parser.add_option(
+ '--version', action="store_true", dest="version", default=False,
+ help="Show grokproject version.")
# Options that override the interactive part of filling the templates.
for var in GrokProject.vars:
@@ -60,10 +64,10 @@
supplied_value = getattr(options, var.name)
if supplied_value is not None:
extra_args.append('%s=%s' % (var.name, supplied_value))
- if options.grokversion:
- extra_args.append('grokversion=%s' % options.grokversion)
+ if options.version_url:
+ extra_args.append('version_url=%s' % options.version_url)
- # Assert that the project name is a valid Python identifier
+ # Assert that the project name is a valid Python identifier.
if not (project_name_re.match(project).group() == project):
print
print "Error: The chosen project name is not a valid " \
@@ -71,9 +75,8 @@
print "Please choose a different project name."
sys.exit(1)
- # Create the project
- exit_code = runner.run(option_args + ['-t', 'grok', project]
- + extra_args)
+ # Create the project.
+ exit_code = runner.run(option_args + ['-t', 'grok', project] + extra_args)
sys.exit(exit_code)
def get_version():
Modified: grokproject/trunk/grokproject/templates.py
===================================================================
--- grokproject/trunk/grokproject/templates.py 2010-10-23 23:14:42 UTC (rev 117828)
+++ grokproject/trunk/grokproject/templates.py 2010-10-25 06:26:54 UTC (rev 117829)
@@ -12,37 +12,39 @@
from grokproject.utils import create_buildout_default_file
from grokproject.utils import exist_buildout_default_file
-GROK_RELEASE_URL_DEFAULT = 'http://grok.zope.org/releaseinfo/'
+GROK_RELEASE_URL = 'http://grok.zope.org/releaseinfo/'
-
class GrokProject(templates.Template):
_template_dir = 'template'
summary = "A grok project"
required_templates = []
vars = [
- ask_var('user', 'Name of an initial administrator user',
- default=NoDefault),
- ask_var('passwd', 'Password for the initial administrator user',
- default=NoDefault, should_echo=False),
- ask_var('newest', 'Check for newer versions of packages',
- default='false', should_ask=False,
- getter=get_boolean_value_for_option),
- ask_var('run_buildout',
- "After creating the project area, run the buildout.",
- default=True, should_ask=False,
- getter=get_boolean_value_for_option),
- ask_var('use_distribute',
- "Use Distribute instead of setuptools for this project.",
- default=False, should_ask=False,
- getter=get_boolean_value_for_option),
- ask_var('eggs_dir',
- 'Location where zc.buildout will look for and place packages',
- default='', should_ask=False),
- ask_var('grok_release_url',
- "URL where grokproject will look up grok version and "
- "release information.",
- should_ask=False),
+ ask_var(
+ 'user', 'Name of an initial administrator user',
+ default=NoDefault),
+ ask_var(
+ 'passwd', 'Password for the initial administrator user',
+ default=NoDefault, should_echo=False),
+ ask_var(
+ 'newest', 'Check for newer versions of packages',
+ default='false', should_ask=False,
+ getter=get_boolean_value_for_option),
+ ask_var(
+ 'run_buildout', (
+ "After creating the project area, run the buildout. "
+ "Defaults to true"),
+ default=True, should_ask=False,
+ getter=get_boolean_value_for_option),
+ ask_var(
+ 'use_distribute',
+ "Use Distribute instead of setuptools for this project.",
+ default=False, should_ask=False,
+ getter=get_boolean_value_for_option),
+ ask_var(
+ 'eggs_dir',
+ 'Location where zc.buildout will look for and place packages',
+ default='', should_ask=False),
]
def check_vars(self, vars, cmd):
@@ -54,8 +56,6 @@
sys.exit(1)
explicit_eggs_dir = vars.get('eggs_dir')
- grok_release_url = vars.get('grok_release_url',
- GROK_RELEASE_URL_DEFAULT)
skipped_vars = {}
for var in list(self.vars):
@@ -74,19 +74,20 @@
vars['app_class_name'] = vars['project'].capitalize()
# Handling the version.cfg file.
- version = vars.get('grokversion')
- if version is None:
+ version_url = vars.get('version_url')
+ find_links_url = ''
+ if version_url is None:
print "Determining current grok version..."
- # if no version was specified, we look up the current version first
- current_info_url = urlparse.urljoin(grok_release_url, 'current')
+ # If no version URL was specified, we look up the current
+ # version first and construct a URL.
+ current_info_url = urlparse.urljoin(GROK_RELEASE_URL, 'current')
version = self.download(current_info_url).strip().replace(
'grok-', '').replace('.cfg', '')
+ version_url = GROK_RELEASE_URL + version + '/versions.cfg'
+ find_links_url = GROK_RELEASE_URL + version + '/eggs'
- if not grok_release_url.endswith('/'):
- grok_release_url += '/'
- base = grok_release_url + version + '/'
- vars['version_info_url'] = base + 'versions.cfg'
- vars['find_links_url'] = base + 'eggs/'
+ vars['find_links_url'] = find_links_url
+ vars['version_info_url'] = version_url
buildout_default = exist_buildout_default_file()
if explicit_eggs_dir:
Modified: grokproject/trunk/tests_paste.txt
===================================================================
--- grokproject/trunk/tests_paste.txt 2010-10-23 23:14:42 UTC (rev 117828)
+++ grokproject/trunk/tests_paste.txt 2010-10-25 06:26:54 UTC (rev 117829)
@@ -12,19 +12,22 @@
>>> # point in the future.
>>> executable = [os.path.join(current_dir, 'bin', 'grokproject')]
>>> opts = ['--user=a', '--passwd=a', '--eggs-dir=' + eggsdir]
- >>> grokversion = ['--grokversion=1.2b']
- >>> sh(executable + opts + grokversion + ['GrokExample'])
+ >>> version = [
+ ... '--version-url=http://grok.zope.org/releaseinfo/1.2b/versions.cfg']
+ >>> sh(executable + opts + version + ['GrokExample'])
['...grokproject',
'--user=a',
'--passwd=a',
'--eggs-dir=...grokproject-test-eggs',
- '--grokversion=1.2b',
+ '--version-url=http://grok.zope.org/releaseinfo/1.2b/versions.cfg',
'GrokExample']
Downloading ...
Creating directory '...bin'.
Creating directory '...parts'.
Creating directory '...develop-eggs'.
+ ...
Generated script '...buildout'.
+ ...
Develop: '...GrokExample...'
...
Generated script '...paster'.
@@ -68,7 +71,9 @@
[buildout]
extends = http://grok.zope.org/releaseinfo/1.2b/versions.cfg
extends-cache = extends-cache
- find-links = http://grok.zope.org/releaseinfo/1.2b/eggs/
+ find-links =
+ include-site-packages = false
+ develop = .
...
>>> ls(package_dir)
More information about the checkins
mailing list