From 0b00a950ebe485a94d2b84441ca643cd67749f31 Mon Sep 17 00:00:00 2001 From: Frederic Lepied Date: Thu, 29 Jul 2004 23:10:05 +0000 Subject: create the intermediate directories before writing a file --- share/ConfigFile.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'share') 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 -- cgit v1.2.1