Do not error out if a section does not exist
authorMikael Berthe <mikael@lilotux.net>
Sat, 21 Jun 2008 19:35:23 +0200
changeset 6 72c249247e18
parent 5 1400a0fa01d4
child 7 727c0c584faa
Do not error out if a section does not exist
mcevent.py
--- a/mcevent.py	Sat Jun 21 19:31:57 2008 +0200
+++ b/mcevent.py	Sat Jun 21 19:35:23 2008 +0200
@@ -73,17 +73,21 @@
     if config.has_option("Notifications", "snd_cmd_msg_in"):
         opt['snd_cmd_msg_in'] = config.get("Notifications", "snd_cmd_msg_in")
 
-    for id in config.options("Contacts"):
-        contact_map[id] = config.get("Contacts", id)
+    if config.has_section("Contacts"):
+        for id in config.options("Contacts"):
+            contact_map[id] = config.get("Contacts", id)
 
-    for id in config.options("Alerts"):
-        online_alerts[id] = int(config.get("Alerts", id))
+    if config.has_section("Alerts"):
+        for id in config.options("Alerts"):
+            online_alerts[id] = int(config.get("Alerts", id))
 
-    for id in config.options("Voicemap"):
-        voicemap[id] = config.get("Voicemap", id)
+    if config.has_section("Voicemap"):
+        for id in config.options("Voicemap"):
+            voicemap[id] = config.get("Voicemap", id)
 
-    for id in config.options("Blacklist"):
-        blacklist[id] = int(config.get("Blacklist", id))
+    if config.has_section("Blacklist"):
+        for id in config.options("Blacklist"):
+            blacklist[id] = int(config.get("Blacklist", id))
 
     if opt['use_notify'] and not NOTIFY_LOADED:
         init_notify()