From 8313035da8e8bc973bcb81eb6d623bdccb218fb2 Mon Sep 17 00:00:00 2001 From: Yuki Watanabe Date: Sat, 28 Sep 2024 22:38:23 +0900 Subject: [PATCH] release: 3.1.0dev7 --- pyproject.toml | 2 +- src/wikidot/module/page.py | 15 ++++++++++++--- src/wikidot/module/site.py | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 58f028f..47aed46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "wikidot" -version = "3.1.0dev6" +version = "3.1.0dev7" authors = [{ name = "ukwhatn", email = "ukwhatn@gmail.com" }] description = "Wikidot Utility Library" readme = "README.md" diff --git a/src/wikidot/module/page.py b/src/wikidot/module/page.py index d1f0605..a27c659 100644 --- a/src/wikidot/module/page.py +++ b/src/wikidot/module/page.py @@ -640,7 +640,7 @@ def create_or_edit( comment: str = "", force_edit: bool = False, raise_on_exists: bool = False, - ): + ) -> "Page": site.client.login_check() # ページロックを取得しにいく @@ -694,7 +694,16 @@ def create_or_edit( } response = site.amc_request([edit_request_body])[0] - return response.json() + if response.json()["status"] != "ok": + raise exceptions.WikidotStatusCodeException( + f"Failed to create or edit page: {fullname}", response.json()["status"] + ) + + res = PageCollection.search_pages(site, SearchPagesQuery(fullname=fullname)) + if len(res) == 0: + raise exceptions.NotFoundException(f"Page creation failed: {fullname}") + + return res[0] def edit( self, @@ -702,7 +711,7 @@ def edit( source: str = None, comment: str = None, force_edit: bool = False, - ): + ) -> "Page": # Noneならそのままにする title = title or self.title source = source or self.source.wiki_text diff --git a/src/wikidot/module/site.py b/src/wikidot/module/site.py index 40c05ea..63fedc8 100644 --- a/src/wikidot/module/site.py +++ b/src/wikidot/module/site.py @@ -74,7 +74,7 @@ def create( source: str = "", comment: str = "", force_edit: bool = False, - ) -> None: + ) -> "Page": """ページを作成する Parameters