Skip to content

Commit

Permalink
Add edit_redirect param to save_page
Browse files Browse the repository at this point in the history
  • Loading branch information
AntiCompositeNumber committed Jan 2, 2023
1 parent db15ee1 commit 48e2125
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions acnutils/__init__.py
Expand Up @@ -28,7 +28,7 @@

from typing import Callable, Any, Dict

__version__ = "0.6.1"
__version__ = "0.6.2"

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -235,6 +235,7 @@ def save_page(
force: bool = False,
new_ok: bool = False,
no_change_ok: bool = False,
edit_redirect: bool = False,
) -> None:
"""Helper for saving a page using Pywikibot.
Expand All @@ -251,6 +252,7 @@ def save_page(
:param new_ok: Allow the creation of new pages, default False
:param no_change_ok: Do not raise `PageNotSaved` if there is no change between
the current text and the new text.
:param edit_redirect: Edit redirect pages instead of raising an exception
"""
logger.info(f"Saving to {page.title()}")
if not text:
Expand All @@ -261,7 +263,7 @@ def save_page(
)

try:
old_text = page.get(force=True)
old_text = page.get(force=True, get_redirect=edit_redirect)
except pywikibot.exceptions.NoPageError as err:
logger.exception(err)
if new_ok:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "acnutils"
version = "0.6.1"
version = "0.6.2"
description = "Various utilities used in AntiCompositeNumber's bots"
authors = ["AntiCompositeNumber <anticompositenumber+pypi@gmail.com>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 48e2125

Please sign in to comment.