def get_sources(source_list=None):
"""
Get a list of all availale Sources.
Expects that source_list is the direct array of Sources loaded from settings.
"""
import pkgutil
import os
pkg_path = os.path.dirname(sources.__file__)
loaded = []
for _,name,_ in pkgutil.iter_modules([pkg_path]):
if '_source' not in name:
continue
fi = __import__(name, fromlist=[''])
for clazz in _module_classes(fi):
if source_list is not None:
for obj in source_list:
cl = clazz() # build the class.
if cl.from_obj(obj):# if the class accepts this data.
loaded.append(cl)
else:
cl = clazz()
loaded.append(cl)
return loaded
评论列表
文章目录