[Treepkg-commits] r97 - trunk/treepkg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jun 23 21:26:22 CEST 2008


Author: bh
Date: 2008-06-23 21:26:21 +0200 (Mon, 23 Jun 2008)
New Revision: 97

Modified:
   trunk/treepkg/packager.py
   trunk/treepkg/util.py
Log:
Move the filenameproperty factory from treepkg/packager.py to
treepkg/util.py


Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py	2008-06-23 16:12:01 UTC (rev 96)
+++ trunk/treepkg/packager.py	2008-06-23 19:26:21 UTC (rev 97)
@@ -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

Modified: trunk/treepkg/util.py
===================================================================
--- trunk/treepkg/util.py	2008-06-23 16:12:01 UTC (rev 96)
+++ trunk/treepkg/util.py	2008-06-23 19:26:21 UTC (rev 97)
@@ -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)



More information about the Treepkg-commits mailing list