X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/6eae78b3d8ed73a0266ef09a30e4b09e791dd9fb..bf58b59267060bdb462476d824b086131b444cd4:/wizard/deploy.py diff --git a/wizard/deploy.py b/wizard/deploy.py index b6d6f66..7908f03 100644 --- a/wizard/deploy.py +++ b/wizard/deploy.py @@ -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."""