• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

news4 - RSS aggrigation system


Commit MetaInfo

Révisionc564c0bf8173fa7738be983e55116c743d5bbdd3 (tree)
l'heure2012-11-01 05:13:49
Auteurhylom <hylom@hylo...>
Commiterhylom

Message de Log

add configloader.py

Change Summary

Modification

--- /dev/null
+++ b/configloader.py
@@ -0,0 +1,27 @@
1+# configloader.py
2+# -*- config: utf-8 -*-
3+
4+import ConfigParser
5+
6+CONFIG_FILE = 'sources.ini'
7+
8+def load():
9+ 'parse .ini file and create config object'
10+ config = ConfigParser.SafeConfigParser()
11+ fp = open(CONFIG_FILE, 'r')
12+ config.readfp(fp)
13+ fp.close()
14+ sources = []
15+ for section in config.sections():
16+ source = {}
17+ source["name"] = section
18+ source["source"] = config.get(section, 'source')
19+ source["url"] = config.get(section, 'url')
20+ if config.has_option(section, 'filters'):
21+ filters = config.get(section, 'filters').split(',')
22+ filters = [x.strip() for x in filters]
23+ source["filters"] = filters
24+ sources.append(source)
25+ return sources
26+
27+