wikidot 3.1.0.dev2__tar.gz → 3.1.0.dev5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wikidot-3.1.0.dev2/src/wikidot.egg-info → wikidot-3.1.0.dev5}/PKG-INFO +1 -1
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/pyproject.toml +1 -1
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/common/exceptions.py +7 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/page.py +88 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/site.py +34 -2
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5/src/wikidot.egg-info}/PKG-INFO +1 -1
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/LICENSE +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/MANIFEST.in +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/README.md +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/setup.cfg +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/__init__.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/common/__init__.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/common/decorators.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/common/logger.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/connector/__init__.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/connector/ajax.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/connector/api.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/__init__.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/auth.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/client.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/forum.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/forum_category.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/forum_group.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/forum_post.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/forum_thread.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/page_revision.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/page_source.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/page_votes.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/private_message.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/site_application.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/module/user.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/__init__.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/parser/__init__.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/parser/odate.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/parser/user.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/quick_module.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/requestutil.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/stringutil.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/table/__init__.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot/util/table/char_table.py +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot.egg-info/SOURCES.txt +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot.egg-info/dependency_links.txt +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot.egg-info/requires.txt +0 -0
- {wikidot-3.1.0.dev2 → wikidot-3.1.0.dev5}/src/wikidot.egg-info/top_level.txt +0 -0
|
@@ -89,6 +89,13 @@ class NotFoundException(WikidotException):
|
|
|
89
89
|
super().__init__(message)
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
class TargetExistsException(WikidotException):
|
|
93
|
+
"""対象が既に存在しているときの例外"""
|
|
94
|
+
|
|
95
|
+
def __init__(self, message):
|
|
96
|
+
super().__init__(message)
|
|
97
|
+
|
|
98
|
+
|
|
92
99
|
class TargetErrorException(WikidotException):
|
|
93
100
|
"""メソッドの対象としたオブジェクトに操作が適用できないときの例外"""
|
|
94
101
|
|
|
@@ -629,3 +629,91 @@ class Page:
|
|
|
629
629
|
}
|
|
630
630
|
]
|
|
631
631
|
)
|
|
632
|
+
|
|
633
|
+
@staticmethod
|
|
634
|
+
def create_or_edit(
|
|
635
|
+
site: "Site",
|
|
636
|
+
fullname: str,
|
|
637
|
+
page_id: int | None = None,
|
|
638
|
+
title: str = "",
|
|
639
|
+
source: str = "",
|
|
640
|
+
comment: str = "",
|
|
641
|
+
force_edit: bool = False,
|
|
642
|
+
raise_on_exists: bool = False,
|
|
643
|
+
):
|
|
644
|
+
site.client.login_check()
|
|
645
|
+
|
|
646
|
+
# ページロックを取得しにいく
|
|
647
|
+
page_lock_request_body = {
|
|
648
|
+
"mode": "page",
|
|
649
|
+
"wiki_page": fullname,
|
|
650
|
+
"moduleName": "edit/PageEditModule",
|
|
651
|
+
}
|
|
652
|
+
if force_edit:
|
|
653
|
+
page_lock_request_body["force_lock"] = "yes"
|
|
654
|
+
|
|
655
|
+
page_lock_response = site.amc_request([page_lock_request_body])[0]
|
|
656
|
+
page_lock_response_data = page_lock_response.json()
|
|
657
|
+
|
|
658
|
+
if (
|
|
659
|
+
"locked" in page_lock_response_data
|
|
660
|
+
or "other_locks" in page_lock_response_data
|
|
661
|
+
):
|
|
662
|
+
raise exceptions.TargetErrorException(
|
|
663
|
+
f"Page {fullname} is locked or other locks exist",
|
|
664
|
+
)
|
|
665
|
+
|
|
666
|
+
# ページが存在するか(page_revision_idがあるか)確認
|
|
667
|
+
is_exist = "page_revision_id" in page_lock_response_data
|
|
668
|
+
|
|
669
|
+
if raise_on_exists and is_exist:
|
|
670
|
+
raise exceptions.TargetExistsException(f"Page {fullname} already exists")
|
|
671
|
+
|
|
672
|
+
if is_exist and page_id is None:
|
|
673
|
+
raise ValueError("page_id must be specified when editing existing page")
|
|
674
|
+
|
|
675
|
+
# lock_idとlock_secret、page_revision_id(あれば)を取得
|
|
676
|
+
lock_id = page_lock_response_data["lock_id"]
|
|
677
|
+
lock_secret = page_lock_response_data["lock_secret"]
|
|
678
|
+
page_revision_id = page_lock_response_data.get("page_revision_id")
|
|
679
|
+
|
|
680
|
+
# ページの作成または編集
|
|
681
|
+
edit_request_body = {
|
|
682
|
+
"action": "WikiPageAction",
|
|
683
|
+
"event": "savePage",
|
|
684
|
+
"moduleName": "Empty",
|
|
685
|
+
"mode": "page",
|
|
686
|
+
"lock_id": lock_id,
|
|
687
|
+
"lock_secret": lock_secret,
|
|
688
|
+
"revision_id": page_revision_id if page_revision_id is not None else "",
|
|
689
|
+
"wiki_page": fullname,
|
|
690
|
+
"page_id": page_id if page_id is not None else "",
|
|
691
|
+
"title": title,
|
|
692
|
+
"source": source,
|
|
693
|
+
"comments": comment,
|
|
694
|
+
}
|
|
695
|
+
response = site.amc_request([edit_request_body])[0]
|
|
696
|
+
|
|
697
|
+
return response.json()
|
|
698
|
+
|
|
699
|
+
def edit(
|
|
700
|
+
self,
|
|
701
|
+
title: str = None,
|
|
702
|
+
source: str = None,
|
|
703
|
+
comment: str = None,
|
|
704
|
+
force_edit: bool = False,
|
|
705
|
+
):
|
|
706
|
+
# Noneならそのままにする
|
|
707
|
+
title = title or self.title
|
|
708
|
+
source = source or self.source.wiki_text
|
|
709
|
+
comment = comment or ""
|
|
710
|
+
|
|
711
|
+
return Page.create_or_edit(
|
|
712
|
+
self.site,
|
|
713
|
+
self.fullname,
|
|
714
|
+
self.id,
|
|
715
|
+
title,
|
|
716
|
+
source,
|
|
717
|
+
comment,
|
|
718
|
+
force_edit,
|
|
719
|
+
)
|
|
@@ -7,12 +7,11 @@ import httpx
|
|
|
7
7
|
from wikidot.common import exceptions
|
|
8
8
|
from wikidot.common.decorators import login_required
|
|
9
9
|
from wikidot.module.forum import Forum
|
|
10
|
-
from wikidot.module.page import PageCollection, SearchPagesQuery
|
|
10
|
+
from wikidot.module.page import Page, PageCollection, SearchPagesQuery
|
|
11
11
|
from wikidot.module.site_application import SiteApplication
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
from wikidot.module.client import Client
|
|
15
|
-
from wikidot.module.page import Page
|
|
16
15
|
from wikidot.module.user import User
|
|
17
16
|
|
|
18
17
|
|
|
@@ -68,6 +67,39 @@ class SitePageMethods:
|
|
|
68
67
|
return None
|
|
69
68
|
return res[0]
|
|
70
69
|
|
|
70
|
+
def create(
|
|
71
|
+
self,
|
|
72
|
+
fullname: str,
|
|
73
|
+
title: str = "",
|
|
74
|
+
source: str = "",
|
|
75
|
+
comment: str = "",
|
|
76
|
+
force_edit: bool = False,
|
|
77
|
+
) -> None:
|
|
78
|
+
"""ページを作成する
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
fullname: str
|
|
83
|
+
ページのフルネーム
|
|
84
|
+
title: str
|
|
85
|
+
ページのタイトル
|
|
86
|
+
source: str
|
|
87
|
+
ページのソース
|
|
88
|
+
comment: str
|
|
89
|
+
コメント
|
|
90
|
+
force_edit: bool
|
|
91
|
+
ページが存在する場合に上書きするかどうか
|
|
92
|
+
"""
|
|
93
|
+
return Page.create_or_edit(
|
|
94
|
+
site=self.site,
|
|
95
|
+
fullname=fullname,
|
|
96
|
+
title=title,
|
|
97
|
+
source=source,
|
|
98
|
+
comment=comment,
|
|
99
|
+
force_edit=force_edit,
|
|
100
|
+
raise_on_exists=True,
|
|
101
|
+
)
|
|
102
|
+
|
|
71
103
|
|
|
72
104
|
@dataclass
|
|
73
105
|
class Site:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|