changeset 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 (2008-06-23)
parents c0ea6cbb0fd2
children 97435e92411a
files treepkg/packager.py treepkg/util.py
diffstat 2 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/treepkg/packager.py	Mon Jun 23 16:12:01 2008 +0000
+++ b/treepkg/packager.py	Mon Jun 23 19:26:21 2008 +0000
@@ -23,16 +23,6 @@
 from cmdexpand import cmdexpand
 from builder import PBuilder
 
-def _filenameproperty(filename, dir_attr="base_dir"):
-    """Create a property for a directory or filename.
-    If the filename is relative it is interpreted as relative to the
-    value of the attribute of self named by dir_attr which defaults to
-    'base_dir'.
-    """
-    def get(self):
-        return os.path.join(getattr(self, dir_attr), filename)
-    return property(get)
-
 def _fromparent(attr):
     """Creates a property that delegates its value to self.parent.<attr>"""
     def get(self):
@@ -224,11 +214,11 @@
         self.status = status.RevisionStatus(os.path.join(self.base_dir,
                                                          "status"))
 
-    log_dir = _filenameproperty("log")
-    work_dir = _filenameproperty("work")
-    binary_dir = _filenameproperty("binary")
-    src_dir = _filenameproperty("src")
-    build_log = _filenameproperty("build_log.txt", dir_attr="log_dir")
+    log_dir = util.filenameproperty("log")
+    work_dir = util.filenameproperty("work")
+    binary_dir = util.filenameproperty("binary")
+    src_dir = util.filenameproperty("src")
+    build_log = util.filenameproperty("build_log.txt", dir_attr="log_dir")
 
     def find_dsc_file(self):
         for filename in os.listdir(self.src_dir):
@@ -321,9 +311,9 @@
         self.pkg_dir_regex \
                    = re.compile(r"(?P<revision>[0-9]+)-(?P<increment>[0-9]+)$")
 
-    checkout_dir = _filenameproperty("checkout")
-    debian_dir = _filenameproperty("debian")
-    pkg_dir = _filenameproperty("pkg")
+    checkout_dir = util.filenameproperty("checkout")
+    debian_dir = util.filenameproperty("debian")
+    pkg_dir = util.filenameproperty("pkg")
 
     def init_treepkg(self):
         print "Initializing", self.name
--- a/treepkg/util.py	Mon Jun 23 16:12:01 2008 +0000
+++ b/treepkg/util.py	Mon Jun 23 19:26:21 2008 +0000
@@ -140,3 +140,14 @@
     f.write(modified)
     f.close()
     return modified != contents
+
+
+def filenameproperty(filename, dir_attr="base_dir"):
+    """Create a property for a directory or filename.
+    If the filename is relative it is interpreted as relative to the
+    value of the attribute of self named by dir_attr which defaults to
+    'base_dir'.
+    """
+    def get(self):
+        return os.path.join(getattr(self, dir_attr), filename)
+    return property(get)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)