Skip to content
Browse files

Init

  • Loading branch information...
0 parents commit 09e554df173a3d315b55f878be90c9ba780265e8 @zerok committed Oct 6, 2008
Showing with 91 additions and 0 deletions.
  1. +25 −0 LICENSE.txt
  2. +12 −0 setup.py
  3. +1 −0 zerokspot/__init__.py
  4. +1 −0 zerokspot/recipe/__init__.py
  5. +52 −0 zerokspot/recipe/git/__init__.py
25 LICENSE.txt
@@ -0,0 +1,25 @@
+Copyright (c) 2008, Horst Gutmann <zerok@zerokspot.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of the author nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 setup.py
@@ -0,0 +1,12 @@
+from setuptools import setup, find_packages
+
+setup(
+ name='zerokspot.recipe.git',
+ author='Horst Gutmann',
+ author_email='zerok@zerokspot.com',
+ version = '0.1',
+ install_requires = ['setuptools', 'zc.buildout'],
+ namespace_packages = ['zerokspot'],
+ packages = find_packages(exclude=['ez_setup']),
+ entry_points = {'zc.buildout': ['default = zerokspot.recipe.git:Recipe']}
+ )
1 zerokspot/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace('zerokspot')
1 zerokspot/recipe/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace('zerokspot.recipe')
52 zerokspot/recipe/git/__init__.py
@@ -0,0 +1,52 @@
+import subprocess
+import os.path
+import zc.buildout
+
+class Recipe(object):
+ """
+ This recipe supports following options:
+
+ repository
+ Path to the repository that should be cloned
+
+ branch
+ Which branch should be cloned. If none is given, "master" is used by
+ default.
+
+ rev
+ Revision that should be used. This is useful if you want to freeze
+ the source at a given revision. If this is used, an update won't do
+ all that much when executed.
+ """
+ def __init__(self, buildout, name, options):
+ self.buildout, self.name, self.options = buildout, name, options
+ self.repository = options['repository']
+ self.branch = options.get('branch', 'master')
+ self.rev = options.get('rev', None)
+ self.target = os.path.join(buildout['buildout']['directory'],
+ 'parts', name)
+
+ def install(self):
+ ec = subprocess.call(r'git clone "%s" "%s"' %
+ (self.repository, self.target), shell=True)
+ if ec != 0:
+ raise zc.buildout.UserError("Failed to clone repository")
+ try:
+ os.chdir(self.target)
+
+ ec = subprocess.call(r'git checkout "%s"' % (self.branch,),
+ shell=True)
+ if ec != 0:
+ raise zc.buildout.UserError("Failed to switch branch")
+
+ if self.rev is not None:
+ ec = subprocess.call(r'git checkout "%s"' % (self.rev,),
+ shell=True)
+ if ec != 0:
+ raise zc.buildout.UserError("Failed to checkout revision")
+ finally:
+ os.chdir(self.buildout['buildout']['directory'])
+ return self.target
+
+ def update(self):
+ pass

0 comments on commit 09e554d

Please sign in to comment.
Something went wrong with that request. Please try again.