Mercurial > treepkg
changeset 135:e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
BinaryPackager. This includes changing how SourcePackager and
BinaryPackager are instantiated -- now the RevisionPackager instance is
given as the first parameter to the __init__ method and most of the
arguments formerly passed to __init__ are now automatiocally taken from
that.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Tue, 27 May 2008 13:12:12 +0000 |
parents | 605f6784aae7 |
children | 5598014b2a1d |
files | treepkg/packager.py |
diffstat | 1 files changed, 22 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/treepkg/packager.py Mon May 26 15:01:00 2008 +0000 +++ b/treepkg/packager.py Tue May 27 13:12:12 2008 +0000 @@ -28,18 +28,26 @@ return os.path.join(self.base_dir, relative_dir) return property(get) +def _fromparent(attr): + """Creates a property that delegates its value to self.parent.<attr>""" + def get(self): + return getattr(self.parent, attr) + return property(get) + class SourcePackager(object): # Derived classes must supply the package basename pkg_basename = None - def __init__(self, track, status, work_dir, src_dir, revision): - self.track = track - self.status = status - self.work_dir = work_dir - self.src_dir = src_dir - self.revision = revision + track = _fromparent("track") + revision = _fromparent("revision") + status = _fromparent("status") + work_dir = _fromparent("work_dir") + src_dir = _fromparent("src_dir") + + def __init__(self, parent): + self.parent = parent assert(self.pkg_basename) def determine_package_version(self, directory): @@ -179,10 +187,12 @@ class BinaryPackager(object): - def __init__(self, track, status, binary_dir, dsc_file, logfile): - self.track = track - self.status = status - self.binary_dir = binary_dir + track = _fromparent("track") + status = _fromparent("status") + binary_dir = _fromparent("binary_dir") + + def __init__(self, parent, dsc_file, logfile): + self.parent = parent self.dsc_file = dsc_file self.logfile = logfile @@ -238,17 +248,14 @@ try: util.ensure_directory(self.work_dir) self.status.start = datetime.datetime.utcnow() - src_packager = self.source_packager_cls(self.track, self.status, - self.work_dir, self.src_dir, - self.revision) + src_packager = self.source_packager_cls(self) src_packager.package() dsc_file = self.find_dsc_file() if dsc_file is None: raise RuntimeError("Cannot find dsc File in %r" % self.src_dir) - bin_packager = self.binary_packager_cls(self.track, self.status, - self.binary_dir, dsc_file, + bin_packager = self.binary_packager_cls(self, dsc_file, self.build_log) bin_packager.package() self.status.stop = datetime.datetime.utcnow()