summaryrefslogtreecommitdiffstats
path: root/tests/helper/parser.py
diff options
context:
space:
mode:
authorGravatar Stefano <l.stickell@yahoo.it> 2013-07-20 22:03:43 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2013-07-20 22:03:43 +0200
commitd1694e31b8b5570508bfbc13cc817dc9b0d8b2a8 (patch)
tree50d89611fab4e02c36155cec663b684167a80252 /tests/helper/parser.py
parentMerge plugins from stable (diff)
parenttried to fix hoster tester, removed unneeded files (diff)
downloadpyload-d1694e31b8b5570508bfbc13cc817dc9b0d8b2a8.tar.xz
Merge branch 'master' of https://github.com/pyload/pyload
Diffstat (limited to 'tests/helper/parser.py')
-rw-r--r--tests/helper/parser.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/helper/parser.py b/tests/helper/parser.py
new file mode 100644
index 000000000..5031ca7c3
--- /dev/null
+++ b/tests/helper/parser.py
@@ -0,0 +1,22 @@
+
+import codecs
+
+def parse_config(path):
+ f = codecs.open(path, "rb", "utf_8")
+ result = {}
+
+ current_section = None
+ for line in f.readlines():
+ line = line.strip()
+ if not line or line.startswith("#"):
+ continue
+
+ if line.startswith("["):
+ current_section = line.replace("[", "").replace("]", "")
+ result[current_section] = []
+ else:
+ if not current_section:
+ raise Exception("Line without section: %s" % line)
+ result[current_section].append(line)
+
+ return result