【问题标题】:Basic custom check python module failing to load基本自定义检查 python 模块加载失败
【发布时间】:2020-12-22 18:19:08
【问题描述】:

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

【问题讨论】:

    标签: weblate


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2019-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-23
      • 1970-01-01
      • 2018-05-01
      • 2014-06-10
      • 2019-11-18
      相关资源
      最近更新 更多