diff options
| author | Alexandre Flament <alex@al-f.net> | 2016-12-09 23:11:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-09 23:11:45 +0100 |
| commit | e48f07a367e55bf8aa881902b977bd7ce1cd2bb6 (patch) | |
| tree | 8b285b2dd483006d08c03b9fec49cba49ff16a87 /searx/utils.py | |
| parent | 219f047bf359ce94397241b875639f3aaddb0fe5 (diff) | |
| parent | d80fb2c8e8995facb3a25c152c47a93eecf1fee4 (diff) | |
Merge branch 'master' into searchpy2
Diffstat (limited to 'searx/utils.py')
| -rw-r--r-- | searx/utils.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py index 5039fa975..faa634853 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -6,7 +6,10 @@ import re from babel.dates import format_date from codecs import getincrementalencoder from HTMLParser import HTMLParser +from imp import load_source +from os.path import splitext, join from random import choice +import sys from searx.version import VERSION_STRING from searx.languages import language_codes @@ -285,3 +288,13 @@ def is_valid_lang(lang): if l[1].lower() == lang.lower(): return (True, l[0][:2], l[1].lower()) return False + + +def load_module(filename, module_dir): + modname = splitext(filename)[0] + if modname in sys.modules: + del sys.modules[modname] + filepath = join(module_dir, filename) + module = load_source(modname, filepath) + module.name = modname + return module |