Author: dmeyer
Date: Fri Feb 24 18:12:46 2006
New Revision: 1220

Modified:
   trunk/base/src/base/distribution.py

Log:
create Configfile class outside extention

Modified: trunk/base/src/base/distribution.py
==============================================================================
--- trunk/base/src/base/distribution.py (original)
+++ trunk/base/src/base/distribution.py Fri Feb 24 18:12:46 2006
@@ -37,7 +37,42 @@
 # version checking
 from version import Version
 
+class Configfile(object):
+    """
+    Config file for the build process.
+    """
+    def __init__(self, filename):
+        self.file = os.path.abspath(filename)
+        # create config file
+        open(self.file, 'w').close()
+
+
+    def append(self, line):
+        """
+        Append something to the config file.
+        """
+        f = open(self.file, 'a')
+        f.write(line + '\n')
+        f.close()
 
+
+    def define(self, variable, value=None):
+        """
+        Set a #define.
+        """
+        if value == None:
+            self.append('#define %s' % variable)
+        else:
+            self.append('#define %s %s' % (variable, value))
+
+            
+    def unlink(self):
+        """
+        Delete config file.
+        """
+        os.unlink(self.file)
+
+        
 class Extension(object):
     """
     Extension wrapper with additional functions to find libraries and
@@ -55,9 +90,7 @@
         self.libraries = libraries
         self.extra_compile_args = ["-Wall"]
         if config:
-            self.configfile = os.path.abspath(config)
-            # create config file
-            open(config, 'w').close()
+            self.configfile = Configfile(config)
         else:
             self.configfile = None
 
@@ -68,9 +101,7 @@
         """
         if not self.configfile:
             raise AttributeError('No config file defined')
-        f = open(self.configfile, 'a')
-        f.write(line + '\n')
-        f.close()
+        self.configfile.append(line)
         
         
     def check_library(self, name, minver):
@@ -150,7 +181,7 @@
         Delete the config file.
         """
         if self.configfile:
-            os.unlink(self.configfile)
+            self.configfile.unlink()
 
 
 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to