source.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:RedditDownloader 作者: shadowmoose 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号