From 5c327ef232522a637c3ea1960569dac697865996 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 9 May 2012 19:17:53 +0200 Subject: Allow a config to be set & created directly --- src/config.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/config.py b/src/config.py index e99572d7..6695c074 100644 --- a/src/config.py +++ b/src/config.py @@ -114,9 +114,12 @@ class Config(RawConfigParser): TODO: make it write also new values in the file, not just what did already exist """ - df = open(self.file_name, 'r') - lines_before = (line.strip() for line in df.readlines()) - df.close() + if path.exists(self.file_name): + df = open(self.file_name, 'r') + lines_before = (line.strip() for line in df.readlines()) + df.close() + else: + lines_before = [] result_lines = [] we_are_in_the_right_section = False written = False -- cgit v1.2.3