From 86a034ff34ffb1e355dd6520204772f3f3108bef Mon Sep 17 00:00:00 2001 From: Yuki Watanabe Date: Sat, 28 Sep 2024 17:17:03 +0900 Subject: [PATCH] release: 3.1.0dev4 --- Makefile | 2 ++ pyproject.toml | 2 +- src/wikidot/module/page.py | 65 ++++++++++++++++++++------------------ src/wikidot/module/site.py | 14 ++++---- 4 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 52d206e..5e90246 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ build: release: echo "Releasing version $(version)" + make format + make lint git add . git commit -m 'release: $(version)' --allow-empty git push origin develop diff --git a/pyproject.toml b/pyproject.toml index f983e3b..3239fc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "wikidot" -version = "3.1.0dev3" +version = "3.1.0dev4" 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 bbd9f7f..e03db25 100644 --- a/src/wikidot/module/page.py +++ b/src/wikidot/module/page.py @@ -99,8 +99,8 @@ def _parse(site: "Site", html_body: BeautifulSoup): # レーティング方式を判定 is_5star_rating = ( - page_element.select_one("span.rating span.page-rate-list-pages-start") - is not None + page_element.select_one("span.rating span.page-rate-list-pages-start") + is not None ) # 各値を取得 @@ -179,17 +179,17 @@ def search_pages(site: "Site", query: SearchPagesQuery = SearchPagesQuery()): query_dict = query.as_dict() query_dict["moduleName"] = "list/ListPagesModule" query_dict["module_body"] = ( - '[[div class="page"]]\n' - + "".join( - [ - f'[[span class="set {key}"]]' - f'[[span class="name"]] {key} [[/span]]' - f'[[span class="value"]] %%{key}%% [[/span]]' - f"[[/span]]" - for key in DEFAULT_MODULE_BODY - ] - ) - + "\n[[/div]]" + '[[div class="page"]]\n' + + "".join( + [ + f'[[span class="set {key}"]]' + f'[[span class="name"]] {key} [[/span]]' + f'[[span class="value"]] %%{key}%% [[/span]]' + f"[[/span]]" + for key in DEFAULT_MODULE_BODY + ] + ) + + "\n[[/div]]" ) try: @@ -320,7 +320,7 @@ def _acquire_page_revisions(site: "Site", pages: list["Page"]): revs = [] body_html = BeautifulSoup(body, "lxml") for rev_element in body_html.select( - "table.page-history > tr[id^=revision-row-]" + "table.page-history > tr[id^=revision-row-]" ): rev_id = int(rev_element["id"].removeprefix("revision-row-")) @@ -545,7 +545,7 @@ def revisions(self) -> PageRevisionCollection["PageRevision"]: @revisions.setter def revisions( - self, value: list["PageRevision"] | PageRevisionCollection["PageRevision"] + self, value: list["PageRevision"] | PageRevisionCollection["PageRevision"] ): self._revisions = value @@ -632,14 +632,14 @@ def delete_meta(self, name: str): @staticmethod def create_or_edit( - site: "Site", - fullname: str, - page_id: int | None = None, - title: str = "", - source: str = "", - comment: str = "", - force_edit: bool = False, - raise_on_exists: bool = False, + site: "Site", + fullname: str, + page_id: int | None = None, + title: str = "", + source: str = "", + comment: str = "", + force_edit: bool = False, + raise_on_exists: bool = False, ): site.client.login_check() @@ -647,7 +647,7 @@ def create_or_edit( page_lock_request_body = { "mode": "page", "wiki_page": fullname, - "moduleName": "edit/PageEditModule" + "moduleName": "edit/PageEditModule", } if force_edit: page_lock_request_body["force_lock"] = "yes" @@ -655,7 +655,10 @@ def create_or_edit( page_lock_response = site.amc_request([page_lock_request_body])[0] page_lock_response_data = page_lock_response.json() - if "locked" in page_lock_response_data or "other_locks" in page_lock_response_data: + if ( + "locked" in page_lock_response_data + or "other_locks" in page_lock_response_data + ): raise exceptions.TargetErrorException( f"Page {fullname} is locked or other locks exist", ) @@ -687,18 +690,18 @@ def create_or_edit( "page_id": page_id if page_id is not None else "", "title": title, "source": source, - "comments": comment + "comments": comment, } response = site.amc_request([edit_request_body])[0] return response.json() def edit( - self, - title: str = None, - source: str = None, - comment: str = None, - force_edit: bool = False, + self, + title: str = None, + source: str = None, + comment: str = None, + force_edit: bool = False, ): # Noneならそのままにする title = title or self.title diff --git a/src/wikidot/module/site.py b/src/wikidot/module/site.py index 834a3b9..ce61338 100644 --- a/src/wikidot/module/site.py +++ b/src/wikidot/module/site.py @@ -69,12 +69,12 @@ def get(self, fullname: str, raise_when_not_found: bool = True) -> Optional["Pag return res[0] def create( - self, - fullname: str, - title: str = "", - source: str = "", - comment: str = "", - force_edit: bool = False, + self, + fullname: str, + title: str = "", + source: str = "", + comment: str = "", + force_edit: bool = False, ) -> None: """ページを作成する @@ -98,7 +98,7 @@ def create( source=source, comment=comment, force_edit=force_edit, - raise_on_exists=True + raise_on_exists=True, )