[Treepkg-commits] r60 - trunk/treepkg
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue May 27 15:12:13 CEST 2008
Author: bh
Date: 2008-05-27 15:12:12 +0200 (Tue, 27 May 2008)
New Revision: 60
Modified:
trunk/treepkg/packager.py
Log:
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.
Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py 2008-05-26 15:01:00 UTC (rev 59)
+++ trunk/treepkg/packager.py 2008-05-27 13:12:12 UTC (rev 60)
@@ -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()
More information about the Treepkg-commits
mailing list