0

我正在尝试将基本检查添加为模块(不是包),但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

4

1 回答 1

0

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

于 2020-09-03T17:47:22.927 回答