Browse Source

Tweaks to support copyvios web tool

main
Ben Kurtovic 1 month ago
parent
commit
9e47e067c2
6 changed files with 39 additions and 9 deletions
  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 View File

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

+ 0
- 1
pyproject.toml View File

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


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


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

+ 17
- 6
src/earwigbot/wiki/__init__.py View File

@@ -41,9 +41,20 @@ of your :py:class:`~earwigbot.wiki.site.Site` (and thus,
:py:class:`~earwigbot.wiki.user.User`) needs. :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 View File

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


import platform import platform


+ 4
- 0
src/earwigbot/wiki/copyvios/__init__.py View File

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


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

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


+ 15
- 0
src/earwigbot/wiki/copyvios/result.py View File

@@ -139,6 +139,20 @@ class CopyvioSource:
event.wait() 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: class CopyvioCheckResult:
""" """
**EarwigBot: Wiki Toolset: Copyvio Check Result** **EarwigBot: Wiki Toolset: Copyvio Check Result**
@@ -177,6 +191,7 @@ class CopyvioCheckResult:
self.possible_miss = possible_miss self.possible_miss = possible_miss
self.included_sources = included_sources if included_sources else [] self.included_sources = included_sources if included_sources else []
self.unified_confidence = unified_confidence self.unified_confidence = unified_confidence
self.metadata = CheckResultMetadata() # Additional metadata for web tool


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


Loading…
Cancel
Save