diff enterprise/kdepim.py @ 111:7f6fb8103db0

Move the sed-like replacement code from enterprise/kdepim.py to treepkg/util.py This creates a new function treepkg.util.replace_in_file with some tests in test/test_util.py and new test support code in test/filesupport.py. Also, adapt enterprise/kdepim.py to use the new function.
author Bernhard Herzog <bh@intevation.de>
date Wed, 19 Mar 2008 19:50:32 +0000
parents 78cf5f6778ec
children
line wrap: on
line diff
--- a/enterprise/kdepim.py	Wed Mar 19 15:00:54 2008 +0000
+++ b/enterprise/kdepim.py	Wed Mar 19 19:50:32 2008 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 by Intevation GmbH
+# Copyright (C) 2007, 2008 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
 #
@@ -44,12 +44,9 @@
         versionstring = "(enterprise %s)" % self.enterprise_version
         for versionfile in ["kmail/kmversion.h", "kontact/src/main.cpp",
                             "korganizer/version.h"]:
-            filename = os.path.join(pkgbasedir, versionfile)
-            patched = re.sub("\(enterprise ([^)]*)\)", versionstring,
-                              open(filename).read())
-            f = open(filename, "w")
-            f.write(patched)
-            f.close()
+            treepkg.util.replace_in_file(os.path.join(pkgbasedir, versionfile),
+                                         "\(enterprise ([^)]*)\)",
+                                         versionstring)
 
     def do_package(self):
         pkgbaseversion, pkgbasedir = self.export_sources()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)