基本的自定义检查python模块无法加载

问题描述

我正在尝试将基本检查添加为模块(不是软件包),但是weblate_celery无法加载。该文件名为ApostropheCheck.py,并与settings.py文件保存在同一目录中。

我将其包含在以下内容中:
import ApostropheCheck
并将其添加到活动支票列表中:

CHECK_LIST += (
    "ApostropheCheck.ApostropheCheck",)

检查代码为:

"""Check for consistent apostrophe usage."""

from django.utils.translation import gettext_lazy as _
from weblate.checks.base import TargetCheck


class ApostropheCheck(TargetCheck):

    # Used as identifier for check,should be unique
    # Has to be shorter than 50 characters
    check_id = "apos"

    # Short name used to display failing check
    name = _("Apostrophe check")

    # Description for failing check
    description = _("Apostophe counts not consistent with source")

    # Real check code
    def check_single(self,source,target,unit):
        if source.count('`') != target.count('`'): return True
        if source.count('"') != target.count('"'): return True
        if source.count("'") != target.count("'"): return True
        return False

解决方法

您需要提供类的完全限定路径,包括Python模块。有关示例,请参见https://docs.weblate.org/en/latest/admin/customize.html#custom-check-modules

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...