Parcourir la source

Tweaks to support copyvios web tool

main
Ben Kurtovic il y a 1 mois
Parent
révision
9e47e067c2
6 fichiers modifiés avec 39 ajouts et 9 suppressions
  1. +2
    -2
      .pre-commit-config.yaml
  2. +0
    -1
      pyproject.toml
  3. +17
    -6
      src/earwigbot/wiki/__init__.py
  4. +1
    -0
      src/earwigbot/wiki/constants.py
  5. +4
    -0
      src/earwigbot/wiki/copyvios/__init__.py
  6. +15
    -0
      src/earwigbot/wiki/copyvios/result.py

+ 2
- 2
.pre-commit-config.yaml Voir le fichier

@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
rev: v0.6.8
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.377
rev: v1.1.383
hooks:
- id: pyright

+ 0
- 1
pyproject.toml Voir le fichier

@@ -68,7 +68,6 @@ target-version = "py311"

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "I", "UP"]
ignore = ["F403"]

[tool.ruff.lint.isort]
known-first-party = ["conftest"]

+ 17
- 6
src/earwigbot/wiki/__init__.py Voir le fichier

@@ -41,9 +41,20 @@ of your :py:class:`~earwigbot.wiki.site.Site` (and thus,
:py:class:`~earwigbot.wiki.user.User`) needs.
"""

from earwigbot.wiki.category import *
from earwigbot.wiki.constants import *
from earwigbot.wiki.page import *
from earwigbot.wiki.site import *
from earwigbot.wiki.sitesdb import *
from earwigbot.wiki.user import *
__all__ = [
"Category",
"Page",
"Site",
"SitesDB",
"User",
]

from earwigbot.wiki import constants
from earwigbot.wiki.category import Category
from earwigbot.wiki.constants import * # noqa: F403
from earwigbot.wiki.page import Page
from earwigbot.wiki.site import Site
from earwigbot.wiki.sitesdb import SitesDB
from earwigbot.wiki.user import User

__all__ += constants.__all__

+ 1
- 0
src/earwigbot/wiki/constants.py Voir le fichier

@@ -57,6 +57,7 @@ __all__ = [
"NS_USER_TALK",
"NS_USER",
"USER_AGENT",
"Service",
]

import platform


+ 4
- 0
src/earwigbot/wiki/copyvios/__init__.py Voir le fichier

@@ -90,6 +90,10 @@ class CopyvioChecker:
def _exclusions_db(self) -> ExclusionsDB | None:
return self._config.get("exclusions_db")

@property
def article_chain(self) -> MarkovChain:
return self._article

def _get_exclusion_callback(self) -> Callable[[str], bool] | None:
if not self._exclusions_db:
return None


+ 15
- 0
src/earwigbot/wiki/copyvios/result.py Voir le fichier

@@ -139,6 +139,20 @@ class CopyvioSource:
event.wait()


class CheckResultMetadata:
def __getattr__(self, key: str) -> Any:
try:
return self.__dict__[key]
except KeyError:
raise AttributeError(key) from None

def __setattr__(self, key: str, val: Any) -> None:
self.__dict__[key] = val

def __delattr__(self, key: str) -> None:
del self.__dict__[key]


class CopyvioCheckResult:
"""
**EarwigBot: Wiki Toolset: Copyvio Check Result**
@@ -177,6 +191,7 @@ class CopyvioCheckResult:
self.possible_miss = possible_miss
self.included_sources = included_sources if included_sources else []
self.unified_confidence = unified_confidence
self.metadata = CheckResultMetadata() # Additional metadata for web tool

def __repr__(self) -> str:
"""Return the canonical string representation of the result."""


Chargement…
Annuler
Enregistrer