Skip to content

Commit

Permalink
release: 3.1.0dev4
Browse files Browse the repository at this point in the history
  • Loading branch information
ukwhatn committed Sep 28, 2024
1 parent c882745 commit 86a034f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 39 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "wikidot"
version = "3.1.0dev3"
version = "3.1.0dev4"
authors = [{ name = "ukwhatn", email = "[email protected]" }]
description = "Wikidot Utility Library"
readme = "README.md"
Expand Down
65 changes: 34 additions & 31 deletions src/wikidot/module/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

# 各値を取得
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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-"))

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -632,30 +632,33 @@ 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()

# ページロックを取得しにいく
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"

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",
)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/wikidot/module/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""ページを作成する
Expand All @@ -98,7 +98,7 @@ def create(
source=source,
comment=comment,
force_edit=force_edit,
raise_on_exists=True
raise_on_exists=True,
)


Expand Down

0 comments on commit 86a034f

Please sign in to comment.