tests.py 文件源码

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

项目:Taigabot 作者: FrozenPigs 项目源码 文件源码
def _check_docstrings(self,obj,errors):
        import enchant
        if hasattr(obj,"__doc__"):
            skip_errors = [w for w in getattr(obj,"_DOC_ERRORS",[])]
            chkr = enchant.checker.SpellChecker("en_AU",obj.__doc__,filters=[enchant.tokenize.URLFilter])
            for err in chkr:
                if len(err.word) == 1:
                    continue
                if err.word.lower() in self.WORDS:
                    continue
                if skip_errors and skip_errors[0] == err.word:
                    skip_errors.pop(0)
                    continue
                errors.append((obj,err.word,err.wordpos))
                msg = "\nDOCSTRING SPELLING ERROR: %s %s %d %s\n" % (obj,err.word,err.wordpos,chkr.suggest())
                printf([msg],file=sys.stderr)
        #  Find and yield all child objects that should be checked
        for name in dir(obj):
            if name.startswith("__"):
                continue
            child = getattr(obj,name)
            if hasattr(child,"__file__"):
                if not hasattr(globals(),"__file__"):
                    continue
                if not child.__file__.startswith(os.path.dirname(__file__)):
                    continue
            else:
                cmod = getattr(child,"__module__",None)
                if not cmod:
                    cclass = getattr(child,"__class__",None)
                    cmod = getattr(cclass,"__module__",None)
                if cmod and not cmod.startswith("enchant"):
                    continue
            yield child
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号