]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/deploy.py
Add mediawiki variable extraction support for deployments.
[wizard.git] / wizard / deploy.py
index b6d6f6648630c2455d703a6974079175097d8fe0..7908f03791591c3fd95a7066ea63b01e14517701 100644 (file)
@@ -27,6 +27,14 @@ class Deployment(object):
         self.location = location
         self._version = version
         self._log = log
+        self._read_cache = {}
+    def read(self, file, force = False):
+        """Reads a file's contents and stuffs it in a cache"""
+        if force or file not in self._read_cache:
+            f = open(os.path.join(self.location, file))
+            self._read_cache[file] = f.read()
+            f.close()
+        return self._read_cache[file]
     @property
     def version_file(self):
         return os.path.join(self.location, '.scripts-version')
@@ -65,6 +73,7 @@ class Application(object):
     def __init__(self, name):
         self.name = name
         self.versions = {}
+        self._extractors = {}
     @property
     def repository(self):
         """Returns the Git repository that would contain this application."""
@@ -76,6 +85,15 @@ class Application(object):
         if version not in self.versions:
             self.versions[version] = ApplicationVersion(distutils.version.LooseVersion(version), self)
         return self.versions[version]
+    def extract(self, deployment):
+        """Extracts wizard variables from a deployment."""
+        result = {}
+        for k,extractor in self.extractors.items():
+            result[k] = extractor(deployment)
+        return result
+    @property
+    def extractors(self):
+        return {}
     @staticmethod
     def make(name):
         """Makes an application, but uses the correct subtype if available."""