Mercurial > treepkg > treepkg
comparison treepkg/packager.py @ 172:06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
treepkg/util.py
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Mon, 23 Jun 2008 19:26:21 +0000 |
parents | be07b88b44ea |
children | 7bde59aa611e |
comparison
equal
deleted
inserted
replaced
171:c0ea6cbb0fd2 | 172:06af36f915f2 |
---|---|
20 import run | 20 import run |
21 import status | 21 import status |
22 import debian | 22 import debian |
23 from cmdexpand import cmdexpand | 23 from cmdexpand import cmdexpand |
24 from builder import PBuilder | 24 from builder import PBuilder |
25 | |
26 def _filenameproperty(filename, dir_attr="base_dir"): | |
27 """Create a property for a directory or filename. | |
28 If the filename is relative it is interpreted as relative to the | |
29 value of the attribute of self named by dir_attr which defaults to | |
30 'base_dir'. | |
31 """ | |
32 def get(self): | |
33 return os.path.join(getattr(self, dir_attr), filename) | |
34 return property(get) | |
35 | 25 |
36 def _fromparent(attr): | 26 def _fromparent(attr): |
37 """Creates a property that delegates its value to self.parent.<attr>""" | 27 """Creates a property that delegates its value to self.parent.<attr>""" |
38 def get(self): | 28 def get(self): |
39 return getattr(self.parent, attr) | 29 return getattr(self.parent, attr) |
222 self.revision = revision | 212 self.revision = revision |
223 self.base_dir = self.track.pkg_dir_for_revision(self.revision, 1) | 213 self.base_dir = self.track.pkg_dir_for_revision(self.revision, 1) |
224 self.status = status.RevisionStatus(os.path.join(self.base_dir, | 214 self.status = status.RevisionStatus(os.path.join(self.base_dir, |
225 "status")) | 215 "status")) |
226 | 216 |
227 log_dir = _filenameproperty("log") | 217 log_dir = util.filenameproperty("log") |
228 work_dir = _filenameproperty("work") | 218 work_dir = util.filenameproperty("work") |
229 binary_dir = _filenameproperty("binary") | 219 binary_dir = util.filenameproperty("binary") |
230 src_dir = _filenameproperty("src") | 220 src_dir = util.filenameproperty("src") |
231 build_log = _filenameproperty("build_log.txt", dir_attr="log_dir") | 221 build_log = util.filenameproperty("build_log.txt", dir_attr="log_dir") |
232 | 222 |
233 def find_dsc_file(self): | 223 def find_dsc_file(self): |
234 for filename in os.listdir(self.src_dir): | 224 for filename in os.listdir(self.src_dir): |
235 if filename.endswith(".dsc"): | 225 if filename.endswith(".dsc"): |
236 return os.path.join(self.src_dir, filename) | 226 return os.path.join(self.src_dir, filename) |
319 self.dependencies = None | 309 self.dependencies = None |
320 self.pkg_dir_template = "%(revision)d-%(increment)d" | 310 self.pkg_dir_template = "%(revision)d-%(increment)d" |
321 self.pkg_dir_regex \ | 311 self.pkg_dir_regex \ |
322 = re.compile(r"(?P<revision>[0-9]+)-(?P<increment>[0-9]+)$") | 312 = re.compile(r"(?P<revision>[0-9]+)-(?P<increment>[0-9]+)$") |
323 | 313 |
324 checkout_dir = _filenameproperty("checkout") | 314 checkout_dir = util.filenameproperty("checkout") |
325 debian_dir = _filenameproperty("debian") | 315 debian_dir = util.filenameproperty("debian") |
326 pkg_dir = _filenameproperty("pkg") | 316 pkg_dir = util.filenameproperty("pkg") |
327 | 317 |
328 def init_treepkg(self): | 318 def init_treepkg(self): |
329 print "Initializing", self.name | 319 print "Initializing", self.name |
330 if not os.path.exists(self.base_dir): | 320 if not os.path.exists(self.base_dir): |
331 print "creating %s" % (self.base_dir,) | 321 print "creating %s" % (self.base_dir,) |