kitty_template_tester.py 文件源码

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

项目:isf 作者: w3h 项目源码 文件源码
def process_file(f, processor):
    try:
        dirpath, filename = os.path.split(f)
        modulename = filename[:-3]
        if dirpath in sys.path:
            sys.path.remove(dirpath)
        sys.path.insert(0, dirpath)
        module = __import__(modulename)
        member_names = dir(module)
        print('Testing file %s' % f)
        for name in member_names:
            try:
                attr = getattr(module, name)
                if isinstance(attr, Template):
                    description = '(member name %s)' % name
                    test_if_template(attr, description, processor)
                elif isinstance(attr, types.ListType):
                    for mem in attr:
                        description = '(element in list %s)' % name
                        test_if_template(mem, description, processor)
                elif isinstance(attr, types.DictionaryType):
                    for k in attr:
                        description = '(%s[%s])' % (name, k)
                        test_if_template(attr[k], description, processor)
                else:
                    attr = None
            except Exception as e:
                print('Exception when testing member %s' % name)
                if processor.verbose:
                    print(traceback.format_exc())
    except Exception as e:
        print('Exception when processing file %s: %s' % (f, e))
        if processor.verbose:
            print(traceback.format_exc())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号