aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2004-07-29 23:10:05 +0000
committerFrederic Lepied <flepied@mandriva.com>2004-07-29 23:10:05 +0000
commit0b00a950ebe485a94d2b84441ca643cd67749f31 (patch)
treeddbdf90cdf4f5498603c5f5a97343ca30160bd95 /share
parent224769ca02fd3d0e015f59297dfba9cefd246883 (diff)
downloadmsec-0b00a950ebe485a94d2b84441ca643cd67749f31.tar
msec-0b00a950ebe485a94d2b84441ca643cd67749f31.tar.gz
msec-0b00a950ebe485a94d2b84441ca643cd67749f31.tar.bz2
msec-0b00a950ebe485a94d2b84441ca643cd67749f31.tar.xz
msec-0b00a950ebe485a94d2b84441ca643cd67749f31.zip
create the intermediate directories before writing a file
Diffstat (limited to 'share')
-rw-r--r--share/ConfigFile.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/share/ConfigFile.py b/share/ConfigFile.py
index 7d9362a..deca335 100644
--- a/share/ConfigFile.py
+++ b/share/ConfigFile.py
@@ -1,6 +1,6 @@
#---------------------------------------------------------------
# Project : Mandrake Linux
-# Module : msec2
+# Module : msec
# File : ConfigFile.py
# Version : $Id$
# Author : Frederic Lepied
@@ -141,6 +141,7 @@ class ConfigFile:
log(_('deleted %s') % (self.path,))
elif self.is_modified:
content = string.join(self.lines, "\n")
+ mkdir_p(self.path)
file = open(self.path, 'w')
file.write(content)
file.close()
@@ -435,4 +436,9 @@ def add_config_assoc(regex, action):
return all_files.add_config_assoc(regex, action)
+def mkdir_p(path):
+ s = os.stat(path)
+ if not s:
+ os.makedirs(os.path.dirname(path))
+
# ConfigFile.py ends here