diff options
| author | 2018-09-29 09:23:40 +0100 | |
|---|---|---|
| committer | 2018-09-29 09:23:40 +0100 | |
| commit | 0f7a122a8447f0b0e9b7d2ef3f57869a277b0348 (patch) | |
| tree | 6ac576fd2b357138dda8cc2f130c202803a4f1ed /src/Utils.py | |
| parent | Correct syntax of event call in Timers.call (diff) | |
Move hashflag parsing to Utils.get_hashflags
Diffstat (limited to 'src/Utils.py')
| -rw-r--r-- | src/Utils.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Utils.py b/src/Utils.py index d5ab69d2..3d1b3a92 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -1,5 +1,5 @@ -import json, re, traceback, urllib.request, urllib.parse, urllib.error, ssl -import string +import io, json, re, traceback, urllib.request, urllib.parse, urllib.error +import ssl, string import bs4 from . import ModuleManager @@ -296,3 +296,20 @@ def export(setting, value): def strip_html(s): return bs4.BeautifulSoup(s, "lxml").get_text() + +def get_hashflags(filename): + hashflags = {} + with io.open(filename, mode="r", encoding="utf8") as f: + for line in f: + line = line.strip("\n") + if not line.startswith("#"): + break + elif line.startswith("#--"): + line_split = line.split(" ", 1) + hashflag = line_split[0][3:] + value = None + + if len(line_split) > 1: + value = line_split[1] + hashflags[hashflag] = value + return hashflags.items() |
