[Checkins] SVN: lovely.recipe/trunk/ new lovely recipe project
Bernd Dorn
bernd.dorn at lovelysystems.com
Mon Jun 4 12:51:02 EDT 2007
Log message for revision 76319:
new lovely recipe project
Changed:
A lovely.recipe/trunk/
A lovely.recipe/trunk/bootstrap.py
A lovely.recipe/trunk/buildout.cfg
A lovely.recipe/trunk/setup.py
A lovely.recipe/trunk/src/
A lovely.recipe/trunk/src/lovely/
A lovely.recipe/trunk/src/lovely/__init__.py
A lovely.recipe/trunk/src/lovely/recipe/
A lovely.recipe/trunk/src/lovely/recipe/__init__.py
A lovely.recipe/trunk/src/lovely/recipe/fs/
A lovely.recipe/trunk/src/lovely/recipe/fs/README.txt
A lovely.recipe/trunk/src/lovely/recipe/fs/__init__.py
A lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
A lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py
A lovely.recipe/trunk/src/lovely/recipe/fs/tests.py
-=-
Added: lovely.recipe/trunk/bootstrap.py
===================================================================
--- lovely.recipe/trunk/bootstrap.py (rev 0)
+++ lovely.recipe/trunk/bootstrap.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# Copyright (c) 2006 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()
+
+try:
+ import pkg_resources
+except ImportError:
+ 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: lovely.recipe/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/buildout.cfg
===================================================================
--- lovely.recipe/trunk/buildout.cfg (rev 0)
+++ lovely.recipe/trunk/buildout.cfg 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,10 @@
+[buildout]
+develop = .
+parts = test
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = lovely.recipe
+
+
+
Property changes on: lovely.recipe/trunk/buildout.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/setup.py
===================================================================
--- lovely.recipe/trunk/setup.py (rev 0)
+++ lovely.recipe/trunk/setup.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+from setuptools import setup, find_packages
+entry_points = """
+[zc.buildout]
+mkdir = lovely.recipe.fs.mkdir:Mkdir
+mkfile = lovely.recipe.fs.mkfile:Mkfile
+"""
+
+setup (
+ name='lovely.recipe',
+ version='0.1dev',
+ author = "Lovely Systems",
+ author_email = "office at lovelysystems.com",
+ license = "ZPL 2.1",
+ keywords = "buildout recipe filesystem",
+ url = 'svn://svn.zope.org/repos/main/lovely.recipe.fs',
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['lovely', 'lovely.recipe'],
+ install_requires = ['setuptools',
+ 'zc.buildout',
+ ],
+ entry_points = entry_points,
+ zip_safe = True,
+ )
Property changes on: lovely.recipe/trunk/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/src/lovely/__init__.py
===================================================================
--- lovely.recipe/trunk/src/lovely/__init__.py (rev 0)
+++ lovely.recipe/trunk/src/lovely/__init__.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,5 @@
+# this is a namespace package
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ pass
Property changes on: lovely.recipe/trunk/src/lovely/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/src/lovely/recipe/__init__.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/__init__.py (rev 0)
+++ lovely.recipe/trunk/src/lovely/recipe/__init__.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,5 @@
+# this is a namespace package
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ pass
Property changes on: lovely.recipe/trunk/src/lovely/recipe/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/src/lovely/recipe/fs/README.txt
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/README.txt (rev 0)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/README.txt 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,72 @@
+==========================
+Filesystem Buildout Recipe
+==========================
+
+Creating Directories
+====================
+
+ >>> write(sample_buildout, 'buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = data-dir
+ ...
+ ... [data-dir]
+ ... recipe = lovely.recipe:mkdir
+ ... path = mystuff
+ ... """)
+ >>> print system(buildout),
+ Installing data-dir.
+ data-dir: Creating directory mystuff
+
+ >>> ls(sample_buildout)
+ - .installed.cfg
+ d bin
+ - buildout.cfg
+ d develop-eggs
+ d eggs
+ d mystuff
+ d parts
+
+Creating Files
+==============
+
+The mkfile recipe creates a file with a given path, content and
+permissions.
+
+ >>> write(sample_buildout, 'buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = script
+ ...
+ ... [script]
+ ... recipe = lovely.recipe:mkfile
+ ... path = file.sh
+ ... content = hoschi
+ ... mode = 0755
+ ... """)
+ >>> print system(buildout)
+ Uninstalling data-dir.
+ Installing script.
+ script: Writing file /sample-buildout/file.sh
+ <BLANKLINE>
+
+ >>> ls(sample_buildout)
+ - .installed.cfg
+ d bin
+ - buildout.cfg
+ d develop-eggs
+ d eggs
+ - file.sh
+ d parts
+
+The content is written to the file.
+
+ >>> cat(sample_buildout, 'file.sh')
+ hoschi
+
+And the mode is set.
+
+ >>> import os, stat
+ >>> path = os.path.join(sample_buildout, 'file.sh')
+ >>> oct(stat.S_IMODE(os.stat(path)[stat.ST_MODE]))
+ '0755'
Property changes on: lovely.recipe/trunk/src/lovely/recipe/fs/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/src/lovely/recipe/fs/__init__.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/__init__.py (rev 0)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/__init__.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1 @@
+#
Property changes on: lovely.recipe/trunk/src/lovely/recipe/fs/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py (rev 0)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,28 @@
+import os
+import logging
+
+class Mkdir:
+
+ def __init__(self, buildout, name, options):
+ self.buildout = buildout
+ self.name = name
+ self.options = options
+ options['path'] = os.path.join(
+ buildout['buildout']['directory'],
+ options['path'],
+ )
+ if not os.path.isdir(os.path.dirname(options['path'])):
+ logging.getLogger(self.name).error(
+ 'Cannot create %s. %s is not a directory.',
+ options['path'], os.path.dirname(options['path']))
+ raise zc.buildout.UserError('Invalid Path')
+
+ def install(self):
+ path = self.options['path']
+ if not os.path.isdir(path):
+ logging.getLogger(self.name).info(
+ 'Creating directory %s', os.path.basename(path))
+ os.mkdir(path)
+ return path
+
+
Property changes on: lovely.recipe/trunk/src/lovely/recipe/fs/mkdir.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py (rev 0)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,32 @@
+import os
+import logging
+
+class Mkfile:
+
+ def __init__(self, buildout, name, options):
+ self.buildout = buildout
+ self.name = name
+ self.options = options
+ self.mode = int(options.get('mode', '0644'), 8)
+ options['content']
+ options['path'] = os.path.join(
+ buildout['buildout']['directory'],
+ options['path'],
+ )
+ if not os.path.isdir(os.path.dirname(options['path'])):
+ logging.getLogger(self.name).error(
+ 'Cannot create file %s. %s is not a directory.',
+ options['path'], os.path.dirname(options['path']))
+ raise zc.buildout.UserError('Invalid Path')
+
+ def install(self):
+ path = self.options['path']
+ f = file(path, 'w')
+ logging.getLogger(self.name).info(
+ 'Writing file %s', path)
+ f.write(self.options['content'])
+
+ f.close()
+ os.chmod(path, self.mode)
+ return path
+
Property changes on: lovely.recipe/trunk/src/lovely/recipe/fs/mkfile.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.recipe/trunk/src/lovely/recipe/fs/tests.py
===================================================================
--- lovely.recipe/trunk/src/lovely/recipe/fs/tests.py (rev 0)
+++ lovely.recipe/trunk/src/lovely/recipe/fs/tests.py 2007-06-04 16:51:00 UTC (rev 76319)
@@ -0,0 +1,19 @@
+from zc.buildout import testing
+import doctest, unittest
+from zope.testing import doctest, renormalizing
+
+def setUp(test):
+ testing.buildoutSetUp(test)
+ testing.install_develop('lovely.recipe', test)
+
+def test_suite():
+
+ return unittest.TestSuite((
+ doctest.DocFileSuite('README.txt',
+ setUp=setUp,
+ tearDown=testing.buildoutTearDown,
+ checker=renormalizing.RENormalizing([
+ testing.normalize_path,
+ testing.normalize_script,
+ testing.normalize_egg_py])
+ )))
Property changes on: lovely.recipe/trunk/src/lovely/recipe/fs/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the Checkins
mailing list