Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edit_redirect param to save_page #31

Merged
merged 1 commit into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions acnutils/__init__.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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