mirror of
https://github.com/searxng/searxng.git
synced 2025-07-30 16:42:22 +02:00
[mod] move load_module function to utils
This commit is contained in:
parent
827f9e41ca
commit
55dc538398
2 changed files with 17 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue