summaryrefslogtreecommitdiff
path: root/eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Common.py
diff options
context:
space:
mode:
authorNishanth Amuluru2011-01-08 11:20:57 +0530
committerNishanth Amuluru2011-01-08 11:20:57 +0530
commit65411d01d448ff0cd4abd14eee14cf60b5f8fc20 (patch)
treeb4c404363c4c63a61d6e2f8bd26c5b057c1fb09d /eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Common.py
parent2e35094d43b4cc6974172e1febf76abb50f086ec (diff)
downloadpytask-65411d01d448ff0cd4abd14eee14cf60b5f8fc20.tar.gz
pytask-65411d01d448ff0cd4abd14eee14cf60b5f8fc20.tar.bz2
pytask-65411d01d448ff0cd4abd14eee14cf60b5f8fc20.zip
Added buildout stuff and made changes accordingly
--HG-- rename : profile/management/__init__.py => eggs/djangorecipe-0.20-py2.6.egg/EGG-INFO/dependency_links.txt rename : profile/management/__init__.py => eggs/djangorecipe-0.20-py2.6.egg/EGG-INFO/not-zip-safe rename : profile/management/__init__.py => eggs/infrae.subversion-1.4.5-py2.6.egg/EGG-INFO/dependency_links.txt rename : profile/management/__init__.py => eggs/infrae.subversion-1.4.5-py2.6.egg/EGG-INFO/not-zip-safe rename : profile/management/__init__.py => eggs/mercurial-1.7.3-py2.6-linux-x86_64.egg/EGG-INFO/dependency_links.txt rename : profile/management/__init__.py => eggs/mercurial-1.7.3-py2.6-linux-x86_64.egg/EGG-INFO/not-zip-safe rename : profile/management/__init__.py => eggs/py-1.4.0-py2.6.egg/EGG-INFO/dependency_links.txt rename : profile/management/__init__.py => eggs/py-1.4.0-py2.6.egg/EGG-INFO/not-zip-safe rename : profile/management/__init__.py => eggs/zc.buildout-1.5.2-py2.6.egg/EGG-INFO/dependency_links.txt rename : profile/management/__init__.py => eggs/zc.buildout-1.5.2-py2.6.egg/EGG-INFO/not-zip-safe rename : profile/management/__init__.py => eggs/zc.recipe.egg-1.3.2-py2.6.egg/EGG-INFO/dependency_links.txt rename : profile/management/__init__.py => eggs/zc.recipe.egg-1.3.2-py2.6.egg/EGG-INFO/not-zip-safe rename : profile/management/__init__.py => parts/django/Django.egg-info/dependency_links.txt rename : taskapp/models.py => parts/django/django/conf/app_template/models.py rename : taskapp/tests.py => parts/django/django/conf/app_template/tests.py rename : taskapp/views.py => parts/django/django/conf/app_template/views.py rename : taskapp/views.py => parts/django/django/contrib/gis/tests/geo3d/views.py rename : profile/management/__init__.py => parts/django/tests/modeltests/delete/__init__.py rename : profile/management/__init__.py => parts/django/tests/modeltests/files/__init__.py rename : profile/management/__init__.py => parts/django/tests/modeltests/invalid_models/__init__.py rename : profile/management/__init__.py => parts/django/tests/modeltests/m2m_signals/__init__.py rename : profile/management/__init__.py => parts/django/tests/modeltests/model_package/__init__.py rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/__init__.py rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/management/__init__.py rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/management/commands/__init__.py rename : profile/management/__init__.py => parts/django/tests/regressiontests/bash_completion/models.py rename : profile/management/__init__.py => parts/django/tests/regressiontests/delete_regress/__init__.py rename : profile/management/__init__.py => parts/django/tests/regressiontests/file_storage/__init__.py rename : profile/management/__init__.py => parts/django/tests/regressiontests/max_lengths/__init__.py rename : profile/forms.py => pytask/profile/forms.py rename : profile/management/__init__.py => pytask/profile/management/__init__.py rename : profile/management/commands/seed_db.py => pytask/profile/management/commands/seed_db.py rename : profile/models.py => pytask/profile/models.py rename : profile/templatetags/user_tags.py => pytask/profile/templatetags/user_tags.py rename : taskapp/tests.py => pytask/profile/tests.py rename : profile/urls.py => pytask/profile/urls.py rename : profile/utils.py => pytask/profile/utils.py rename : profile/views.py => pytask/profile/views.py rename : static/css/base.css => pytask/static/css/base.css rename : taskapp/tests.py => pytask/taskapp/tests.py rename : taskapp/views.py => pytask/taskapp/views.py rename : templates/base.html => pytask/templates/base.html rename : templates/profile/browse_notifications.html => pytask/templates/profile/browse_notifications.html rename : templates/profile/edit.html => pytask/templates/profile/edit.html rename : templates/profile/view.html => pytask/templates/profile/view.html rename : templates/profile/view_notification.html => pytask/templates/profile/view_notification.html rename : templates/registration/activate.html => pytask/templates/registration/activate.html rename : templates/registration/activation_email.txt => pytask/templates/registration/activation_email.txt rename : templates/registration/activation_email_subject.txt => pytask/templates/registration/activation_email_subject.txt rename : templates/registration/logged_out.html => pytask/templates/registration/logged_out.html rename : templates/registration/login.html => pytask/templates/registration/login.html rename : templates/registration/logout.html => pytask/templates/registration/logout.html rename : templates/registration/password_change_done.html => pytask/templates/registration/password_change_done.html rename : templates/registration/password_change_form.html => pytask/templates/registration/password_change_form.html rename : templates/registration/password_reset_complete.html => pytask/templates/registration/password_reset_complete.html rename : templates/registration/password_reset_confirm.html => pytask/templates/registration/password_reset_confirm.html rename : templates/registration/password_reset_done.html => pytask/templates/registration/password_reset_done.html rename : templates/registration/password_reset_email.html => pytask/templates/registration/password_reset_email.html rename : templates/registration/password_reset_form.html => pytask/templates/registration/password_reset_form.html rename : templates/registration/registration_complete.html => pytask/templates/registration/registration_complete.html rename : templates/registration/registration_form.html => pytask/templates/registration/registration_form.html rename : utils.py => pytask/utils.py
Diffstat (limited to 'eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Common.py')
-rw-r--r--eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Common.py244
1 files changed, 244 insertions, 0 deletions
diff --git a/eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Common.py b/eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Common.py
new file mode 100644
index 0000000..234ef6b
--- /dev/null
+++ b/eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Common.py
@@ -0,0 +1,244 @@
+# Copyright (c) 2007-2008 Infrae. All rights reserved.
+# $Id: Common.py 33243 2009-01-29 10:59:47Z sylvain $
+
+from sets import Set # For python 2.3 compatibility
+import os.path
+import os
+import re
+
+
+import zc.buildout
+
+
+def ignoredFile(file):
+ """Return true if the file should be ignored while checking for
+ added/changed/modified files.
+ """
+ for suffix in ['.pyc', '.pyo', '.egg-info']:
+ if file.endswith(suffix):
+ return True
+ return False
+
+
+def reportInvalidFiles(path, name, badfiles):
+ """Report invalid files.
+ """
+ badfiles = [file for file in badfiles if not ignoredFile(file)]
+ if not badfiles:
+ return
+ raise ValueError("""\
+In '%s':
+local modifications detected while uninstalling %r: Uninstall aborted!
+
+Please check for local modifications and make sure these are checked
+in.
+
+If you sure that these modifications can be ignored, remove the
+checkout manually:
+
+ rm -rf %s
+
+Or if applicable, add the file to the 'svn:ignore' property of the
+file's container directory. Alternatively, add an ignore glob pattern
+to your subversion client's 'global-ignores' configuration variable.
+""" % (path, name, """
+ rm -rf """.join(badfiles)))
+
+
+def checkExistPath(path, warning=True):
+ """Check that a path exist.
+ """
+ status = os.path.exists(path)
+ if not status and warning:
+ print "-------- WARNING --------"
+ print "Directory %s have been removed." % os.path.abspath(path)
+ print "Changes might be lost."
+ print "-------- WARNING --------"
+ return status
+
+
+def checkAddedPaths(location, urls):
+ """Check that no path have been added to that location.
+ """
+ current_paths = Set([os.path.join(location, s) for s in
+ os.listdir(location)])
+ recipe_paths = Set(urls.keys())
+ added_paths = list(current_paths - recipe_paths)
+ for path in added_paths[:]:
+ if path.endswith('.svn'):
+ added_paths.remove(path)
+ if added_paths:
+ msg = "New path have been added to the location: %s."
+ raise ValueError(msg % ', '.join(added_paths))
+
+
+def prepareURLs(location, urls):
+ """Given a list of urls/path, and a location, prepare a list of
+ tuple with url, full path.
+ """
+
+ def prepareEntry(line):
+ link, path = line.split()
+ return os.path.join(location, path), link
+
+ return dict([prepareEntry(l) for l in urls.splitlines() if l.strip()])
+
+
+def extractNames(urls):
+ """Return just the target names of the urls (used for egg names)"""
+
+ def extractName(line):
+ link, name = line.split()
+ return name
+
+ return [extractName(line) for line in urls.splitlines() if line.strip()]
+
+
+class BaseRecipe(object):
+ """infrae.subversion recipe. Base class.
+ """
+
+ def __init__(self, buildout, name, options):
+ self.buildout = buildout
+ self.name = name
+ self.options = options
+ # location is overridable if desired.
+ location = options.get('location', None)
+ if location:
+ self.location = os.path.abspath(os.path.join(
+ buildout['buildout']['directory'], location))
+ else:
+ self.location = os.path.join(
+ buildout['buildout']['parts-directory'], self.name)
+ options['location'] = self.location
+ self.revisions = {} # Store revision information for each link
+ self.updated = [] # Store updated links
+ self.urls = prepareURLs(self.location, options['urls'])
+ self.export = options.get('export')
+ self.offline = buildout['buildout'].get('offline', 'false') == 'true'
+ self.eggify = options.get('as_eggs', False)
+ self.eggs = self.eggify and extractNames(options['urls']) or []
+ self.newest = (
+ not self.offline and
+ buildout['buildout'].get('newest', 'true') == 'true'
+ )
+ self.verbose = buildout['buildout'].get('verbosity', 0)
+ self.warning = not (options.get('no_warnings', 'false') == 'true')
+
+ def _exportInformationToOptions(self):
+ """Export revision and changed information to options.
+
+ Options can only contains strings.
+ """
+ if self.options.get('export_info', False):
+ self.options['updated'] = str('\n'.join(self.updated))
+ str_revisions = ['%s %s' % r for r in self.revisions.items()
+ if r[1]]
+ self.options['revisions'] = str('\n'.join(sorted(str_revisions)))
+ # Always export egg list
+ self.options['eggs'] = '\n'.join(sorted(self.eggs))
+
+ def _updateAllRevisionInformation(self):
+ """Update all revision information for defined urls.
+ """
+ for path, link in self.urls.items():
+ if os.path.exists(path):
+ self._updateRevisionInformation(link, path)
+
+ def _updateRevisionInformation(self, link, revision):
+ """Update revision information on a path.
+ """
+ old_revision = self.revisions.get(link, None)
+ self.revisions[link] = revision
+ if not (old_revision is None):
+ self.updated.append(link)
+
+ def _updatePath(self, link, path):
+ """Update a single path.
+ """
+ raise NotImplementedError
+
+ def _updateAllPaths(self):
+ """Update the checkouts.
+ """
+ ignore = self.options.get('ignore_updates', False) or self.export
+
+ num_release = re.compile('.*@[0-9]+$')
+ for path, link in self.urls.items():
+ if not checkExistPath(path, warning=self.warning):
+ if self.verbose:
+ print "Entry %s missing, checkout a new version ..." % link
+ self._installPath(link, path)
+ continue
+
+ if ignore:
+ continue
+
+ if num_release.match(link):
+ if self.verbose:
+ print "Given num release for %s, skipping." % link
+ continue
+
+ if self.verbose:
+ print "Updating %s" % path
+ self._updatePath(link, path)
+
+ def update(self):
+ """Update the recipe.
+
+ Does not update SVN path if the buildout is in offline mode,
+ but still eggify and export information.
+ """
+ if self.newest:
+ self._updateAllPaths()
+
+ if self.eggify:
+ self._eggify()
+ self._exportInformationToOptions()
+ return self.location
+
+ def _installPath(self, link, path):
+ """Checkout a single entry.
+ """
+ raise NotImplementedError
+
+ def _installPathVerbose(self, link, path):
+ """Checkout a single entry with verbose.
+ """
+ if self.verbose:
+ print "%s %s to %s" % (self.export and 'Export' or 'Fetch',
+ link, path)
+ self._installPath(link, path)
+
+ def _eggify(self):
+ """Install everything as development eggs if eggs=true"""
+ if self.eggify:
+ target = self.buildout['buildout']['develop-eggs-directory']
+ for path in self.urls.keys():
+ # If we update the recipe, and we don't have newest,
+ # and that some path have been deleted, all of them
+ # might not be there.
+ if checkExistPath(path, warning=self.warning):
+ zc.buildout.easy_install.develop(path, target)
+
+ def install(self):
+ """Checkout the checkouts.
+
+ Fails if buildout is running in offline mode.
+ """
+
+ for path, link in self.urls.items():
+ self._installPathVerbose(link, path)
+ installed = [self.location]
+
+ if self.eggify:
+ self._eggify()
+ # And also return the develop-eggs/*.egg-link files that are
+ # ours so that an uninstall automatically zaps them.
+ dev_dir = self.buildout['buildout']['develop-eggs-directory']
+ egg_links = ['%s.egg-link' % egg for egg in self.eggs]
+ egg_links = [os.path.join(dev_dir, link) for link in egg_links]
+ installed += egg_links
+ self._exportInformationToOptions()
+
+ return installed