Horst Gutmann avatar Horst Gutmann committed d093e0a

PEP8'ified the code a bit

This means mostly docstrings, spaces vs. tabs and no longer >80 chars long
lines.

Comments (0)

Files changed (1)

mercurialrecipe/__init__.py

+"""
+This recipe offers you an easy way to integration data from some Mercurial
+repository into your buildout work-environment::
+
+    [some_hg_dependency]
+    recipe = mercurialrecipe
+    repository = <REPOSITORY PATH/URL>
+
+"""
 import os
 import shutil
 import logging
 from mercurial import commands, ui, hg
 
+
 def get_repository(location):
-	return hg.repository(ui.ui(), location)
+    "Builds a Mercurial repository object out of the given location."
+    return hg.repository(ui.ui(), location)
+
 
 class Recipe(object):
-	
-	def __init__(self, buildout, name, options):
-		self.options = options
-		self.options.setdefault('location', os.path.join(buildout.get('buildout').get('parts-directory'), name))
-		self.source = self.options.get('repository')
-		self.destination = self.options.get('location')
-		self.newest = options.get('newest', buildout.get('buildout').get('newest', 'true')).lower() != 'false'
-		self.log = logging.getLogger(name)
-	
-	def install(self):
-		self.log.info("Cloning repository %s to %s" % (self.source, self.destination))
-		shutil.rmtree(self.destination, ignore_errors = True)
-		commands.clone(ui.ui(), get_repository(self.source), self.destination)
-		return self.destination
-	
-	def update(self):
-		if self.newest:
-			self.log.info("Pulling repository %s and updating %s" % (self.source, self.destination))
-			commands.pull(ui.ui(), get_repository(self.destination), self.source, update = True)
+    """
+    This is the recipe itself, for details on how to use it,
+    please take a look at the module documentation.
+    """
+
+    def __init__(self, buildout, name, options):
+        self.options = options
+        self.options.setdefault('location',
+            os.path.join(buildout.get('buildout') \
+                .get('parts-directory'), name))
+        self.source = self.options.get('repository')
+        self.destination = self.options.get('location')
+        self.newest = options.get('newest',
+            buildout.get('buildout') \
+                .get('newest', 'true')).lower() != 'false'
+        self.log = logging.getLogger(name)
+
+    def install(self):
+        """
+        Does the actual installation of this part.
+
+        Be aware, that if the part was previously installed, it will
+        get removed.
+        """
+        self.log.info("Cloning repository %s to %s" % (
+            self.source, self.destination
+        ))
+        shutil.rmtree(self.destination, ignore_errors = True)
+        commands.clone(ui.ui(), get_repository(self.source), self.destination)
+        return self.destination
+
+    def update(self):
+        """
+        This method is run when a buildout environment should be updated. If
+        the ``newest`` option is set, this will cause a pull from the upstream
+        repository.
+        """
+        if self.newest:
+            self.log.info("Pulling repository %s and updating %s" % (
+                self.source, self.destination
+            ))
+            commands.pull(ui.ui(), get_repository(self.destination),
+                    self.source, update = True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.