wikidot 3.1.0.dev9__tar.gz → 3.1.0.dev11__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.
Files changed (70) hide show
  1. wikidot-3.1.0.dev11/PKG-INFO +101 -0
  2. wikidot-3.1.0.dev11/README.md +68 -0
  3. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/pyproject.toml +26 -7
  4. wikidot-3.1.0.dev11/src/wikidot/__init__.py +57 -0
  5. wikidot-3.1.0.dev11/src/wikidot/common/__init__.py +10 -0
  6. wikidot-3.1.0.dev11/src/wikidot/common/decorators.py +77 -0
  7. wikidot-3.1.0.dev11/src/wikidot/common/exceptions.py +259 -0
  8. wikidot-3.1.0.dev11/src/wikidot/common/logger.py +43 -0
  9. wikidot-3.1.0.dev11/src/wikidot/connector/__init__.py +7 -0
  10. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/connector/ajax.py +113 -87
  11. wikidot-3.1.0.dev11/src/wikidot/module/__init__.py +7 -0
  12. wikidot-3.1.0.dev11/src/wikidot/module/auth.py +90 -0
  13. wikidot-3.1.0.dev11/src/wikidot/module/client.py +326 -0
  14. wikidot-3.1.0.dev11/src/wikidot/module/forum_category.py +285 -0
  15. wikidot-3.1.0.dev11/src/wikidot/module/forum_post.py +143 -0
  16. wikidot-3.1.0.dev11/src/wikidot/module/forum_thread.py +450 -0
  17. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/module/page.py +592 -96
  18. wikidot-3.1.0.dev11/src/wikidot/module/page_revision.py +302 -0
  19. wikidot-3.1.0.dev11/src/wikidot/module/page_source.py +31 -0
  20. wikidot-3.1.0.dev11/src/wikidot/module/page_votes.py +89 -0
  21. wikidot-3.1.0.dev11/src/wikidot/module/private_message.py +408 -0
  22. wikidot-3.1.0.dev11/src/wikidot/module/site.py +532 -0
  23. wikidot-3.1.0.dev11/src/wikidot/module/site_application.py +185 -0
  24. wikidot-3.1.0.dev11/src/wikidot/module/site_member.py +272 -0
  25. wikidot-3.1.0.dev11/src/wikidot/module/user.py +336 -0
  26. wikidot-3.1.0.dev11/src/wikidot/util/__init__.py +7 -0
  27. wikidot-3.1.0.dev11/src/wikidot/util/parser/__init__.py +11 -0
  28. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/util/parser/user.py +4 -4
  29. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/util/quick_module.py +21 -3
  30. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/util/requestutil.py +2 -6
  31. wikidot-3.1.0.dev11/src/wikidot/util/table/__init__.py +6 -0
  32. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/util/table/char_table.py +12 -0
  33. wikidot-3.1.0.dev11/src/wikidot.egg-info/PKG-INFO +101 -0
  34. wikidot-3.1.0.dev11/src/wikidot.egg-info/requires.txt +21 -0
  35. wikidot-3.1.0.dev9/PKG-INFO +0 -111
  36. wikidot-3.1.0.dev9/README.md +0 -82
  37. wikidot-3.1.0.dev9/src/wikidot/__init__.py +0 -1
  38. wikidot-3.1.0.dev9/src/wikidot/common/__init__.py +0 -1
  39. wikidot-3.1.0.dev9/src/wikidot/common/decorators.py +0 -36
  40. wikidot-3.1.0.dev9/src/wikidot/common/exceptions.py +0 -122
  41. wikidot-3.1.0.dev9/src/wikidot/common/logger.py +0 -18
  42. wikidot-3.1.0.dev9/src/wikidot/connector/__init__.py +0 -0
  43. wikidot-3.1.0.dev9/src/wikidot/module/__init__.py +0 -0
  44. wikidot-3.1.0.dev9/src/wikidot/module/auth.py +0 -75
  45. wikidot-3.1.0.dev9/src/wikidot/module/client.py +0 -220
  46. wikidot-3.1.0.dev9/src/wikidot/module/forum_category.py +0 -112
  47. wikidot-3.1.0.dev9/src/wikidot/module/forum_post.py +0 -53
  48. wikidot-3.1.0.dev9/src/wikidot/module/forum_thread.py +0 -148
  49. wikidot-3.1.0.dev9/src/wikidot/module/page_revision.py +0 -128
  50. wikidot-3.1.0.dev9/src/wikidot/module/page_source.py +0 -11
  51. wikidot-3.1.0.dev9/src/wikidot/module/page_votes.py +0 -23
  52. wikidot-3.1.0.dev9/src/wikidot/module/private_message.py +0 -313
  53. wikidot-3.1.0.dev9/src/wikidot/module/site.py +0 -310
  54. wikidot-3.1.0.dev9/src/wikidot/module/site_application.py +0 -112
  55. wikidot-3.1.0.dev9/src/wikidot/module/site_member.py +0 -97
  56. wikidot-3.1.0.dev9/src/wikidot/module/user.py +0 -281
  57. wikidot-3.1.0.dev9/src/wikidot/util/__init__.py +0 -0
  58. wikidot-3.1.0.dev9/src/wikidot/util/parser/__init__.py +0 -2
  59. wikidot-3.1.0.dev9/src/wikidot/util/table/__init__.py +0 -0
  60. wikidot-3.1.0.dev9/src/wikidot.egg-info/PKG-INFO +0 -111
  61. wikidot-3.1.0.dev9/src/wikidot.egg-info/requires.txt +0 -16
  62. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/LICENSE +0 -0
  63. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/MANIFEST.in +0 -0
  64. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/setup.cfg +0 -0
  65. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/connector/api.py +0 -0
  66. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/util/parser/odate.py +0 -0
  67. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot/util/stringutil.py +0 -0
  68. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot.egg-info/SOURCES.txt +0 -0
  69. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot.egg-info/dependency_links.txt +0 -0
  70. {wikidot-3.1.0.dev9 → wikidot-3.1.0.dev11}/src/wikidot.egg-info/top_level.txt +0 -0
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.2
2
+ Name: wikidot
3
+ Version: 3.1.0.dev11
4
+ Summary: Wikidot Utility Library
5
+ Author-email: ukwhatn <ukwhatn@gmail.com>
6
+ Project-URL: Homepage, https://github.com/ukwhatn/wikidot.py
7
+ Project-URL: Bug Tracker, https://github.com/ukwhatn/wikidot.py/issues
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: httpx<0.29,>=0.25
17
+ Requires-Dist: beautifulsoup4<4.14.0,>=4.12.2
18
+ Requires-Dist: lxml<5.4.0,>=4.9.3
19
+ Provides-Extra: build
20
+ Requires-Dist: build; extra == "build"
21
+ Requires-Dist: twine; extra == "build"
22
+ Provides-Extra: lint
23
+ Requires-Dist: ruff; extra == "lint"
24
+ Requires-Dist: mypy; extra == "lint"
25
+ Provides-Extra: format
26
+ Requires-Dist: ruff; extra == "format"
27
+ Provides-Extra: docs
28
+ Requires-Dist: sphinx>=7.2.6; extra == "docs"
29
+ Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == "docs"
30
+ Requires-Dist: sphinx-intl>=2.1.0; extra == "docs"
31
+ Requires-Dist: myst-parser>=2.0.0; extra == "docs"
32
+ Requires-Dist: sphinx-autodoc-typehints>=1.25.3; extra == "docs"
33
+
34
+ # wikidot.py
35
+
36
+ [![Documentation Status](https://github.com/ukwhatn/wikidot.py/actions/workflows/docs.yml/badge.svg)](https://ukwhatn.github.io/wikidot.py/)
37
+
38
+ Pythonで簡単にWikidotサイトと対話するためのライブラリです。
39
+
40
+ ## 主な機能
41
+
42
+ - サイト、ページ、ユーザー、フォーラムなどの情報取得と操作
43
+ - ページの作成、編集、削除
44
+ - フォーラムスレッドの取得、作成、返信
45
+ - ユーザー管理とサイトメンバーシップ
46
+ - プライベートメッセージの送受信
47
+ - ログイン不要の機能と認証が必要な機能両方をサポート
48
+
49
+ ## インストール
50
+
51
+ ```bash
52
+ pip install wikidot
53
+ ```
54
+
55
+ ## 使用例(基本)
56
+
57
+ ```python
58
+ import wikidot
59
+
60
+ # ログインなしでの使用
61
+ client = wikidot.Client()
62
+
63
+ # サイトとページの情報取得
64
+ site = client.site.get("scp-jp")
65
+ page = site.page.get("scp-173")
66
+
67
+ print(f"タイトル: {page.title}")
68
+ print(f"評価: {page.rating}")
69
+ print(f"作成者: {page.created_by.name}")
70
+ ```
71
+
72
+ ## ドキュメント
73
+
74
+ 詳細な使用方法、APIリファレンス、例は公式ドキュメントをご覧ください:
75
+
76
+ 📚 **[公式ドキュメント](https://ukwhatn.github.io/wikidot.py/)**
77
+
78
+ - [インストール方法](https://ukwhatn.github.io/wikidot.py/installation.html)
79
+ - [クイックスタート](https://ukwhatn.github.io/wikidot.py/quickstart.html)
80
+ - [使用例](https://ukwhatn.github.io/wikidot.py/examples.html)
81
+ - [APIリファレンス](https://ukwhatn.github.io/wikidot.py/reference/index.html)
82
+
83
+ ## ドキュメント構築
84
+
85
+ ローカルでドキュメントを構築するには:
86
+
87
+ ```bash
88
+ # ドキュメント生成に必要なパッケージをインストール
89
+ make docs-install
90
+
91
+ # ドキュメントをビルド
92
+ make docs-build
93
+
94
+ # ローカルサーバーでドキュメントを確認(オプション)
95
+ make docs-serve
96
+ ```
97
+
98
+ ## Contribution
99
+
100
+ - [ロードマップ](https://ukwhatn.notion.site/wikidot-py-roadmap?pvs=4)
101
+ - [Issue](https://github.com/ukwhatn/wikidot.py/issues)
@@ -0,0 +1,68 @@
1
+ # wikidot.py
2
+
3
+ [![Documentation Status](https://github.com/ukwhatn/wikidot.py/actions/workflows/docs.yml/badge.svg)](https://ukwhatn.github.io/wikidot.py/)
4
+
5
+ Pythonで簡単にWikidotサイトと対話するためのライブラリです。
6
+
7
+ ## 主な機能
8
+
9
+ - サイト、ページ、ユーザー、フォーラムなどの情報取得と操作
10
+ - ページの作成、編集、削除
11
+ - フォーラムスレッドの取得、作成、返信
12
+ - ユーザー管理とサイトメンバーシップ
13
+ - プライベートメッセージの送受信
14
+ - ログイン不要の機能と認証が必要な機能両方をサポート
15
+
16
+ ## インストール
17
+
18
+ ```bash
19
+ pip install wikidot
20
+ ```
21
+
22
+ ## 使用例(基本)
23
+
24
+ ```python
25
+ import wikidot
26
+
27
+ # ログインなしでの使用
28
+ client = wikidot.Client()
29
+
30
+ # サイトとページの情報取得
31
+ site = client.site.get("scp-jp")
32
+ page = site.page.get("scp-173")
33
+
34
+ print(f"タイトル: {page.title}")
35
+ print(f"評価: {page.rating}")
36
+ print(f"作成者: {page.created_by.name}")
37
+ ```
38
+
39
+ ## ドキュメント
40
+
41
+ 詳細な使用方法、APIリファレンス、例は公式ドキュメントをご覧ください:
42
+
43
+ 📚 **[公式ドキュメント](https://ukwhatn.github.io/wikidot.py/)**
44
+
45
+ - [インストール方法](https://ukwhatn.github.io/wikidot.py/installation.html)
46
+ - [クイックスタート](https://ukwhatn.github.io/wikidot.py/quickstart.html)
47
+ - [使用例](https://ukwhatn.github.io/wikidot.py/examples.html)
48
+ - [APIリファレンス](https://ukwhatn.github.io/wikidot.py/reference/index.html)
49
+
50
+ ## ドキュメント構築
51
+
52
+ ローカルでドキュメントを構築するには:
53
+
54
+ ```bash
55
+ # ドキュメント生成に必要なパッケージをインストール
56
+ make docs-install
57
+
58
+ # ドキュメントをビルド
59
+ make docs-build
60
+
61
+ # ローカルサーバーでドキュメントを確認(オプション)
62
+ make docs-serve
63
+ ```
64
+
65
+ ## Contribution
66
+
67
+ - [ロードマップ](https://ukwhatn.notion.site/wikidot-py-roadmap?pvs=4)
68
+ - [Issue](https://github.com/ukwhatn/wikidot.py/issues)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wikidot"
3
- version = "3.1.0dev9"
3
+ version = "3.1.0dev11"
4
4
  authors = [{ name = "ukwhatn", email = "ukwhatn@gmail.com" }]
5
5
  description = "Wikidot Utility Library"
6
6
  readme = "README.md"
@@ -15,7 +15,7 @@ classifiers = [
15
15
 
16
16
  dependencies = [
17
17
  "httpx >= 0.25,< 0.29",
18
- "beautifulsoup4 ~= 4.12.2",
18
+ "beautifulsoup4 >= 4.12.2,< 4.14.0",
19
19
  "lxml >= 4.9.3,< 5.4.0",
20
20
  ]
21
21
 
@@ -25,15 +25,34 @@ build = [
25
25
  "twine",
26
26
  ]
27
27
  lint = [
28
- "flake8",
28
+ "ruff",
29
29
  "mypy",
30
- "isort",
31
30
  ]
32
31
  format = [
33
- "black",
34
- "isort",
32
+ "ruff",
33
+ ]
34
+ docs = [
35
+ "sphinx>=7.2.6",
36
+ "sphinx-rtd-theme>=2.0.0",
37
+ "sphinx-intl>=2.1.0",
38
+ "myst-parser>=2.0.0",
39
+ "sphinx-autodoc-typehints>=1.25.3",
35
40
  ]
36
41
 
37
42
  [project.urls]
38
43
  "Homepage" = "https://github.com/ukwhatn/wikidot.py"
39
- "Bug Tracker" = "https://github.com/ukwhatn/wikidot.py/issues"
44
+ "Bug Tracker" = "https://github.com/ukwhatn/wikidot.py/issues"
45
+
46
+ [tool.ruff]
47
+ target-version = "py310"
48
+ line-length = 120
49
+ lint.select = ["E", "F", "I"]
50
+ lint.ignore = []
51
+
52
+ [tool.ruff.format]
53
+ quote-style = "double"
54
+ indent-style = "space"
55
+ line-ending = "auto"
56
+
57
+ [tool.ruff.lint.isort]
58
+ known-first-party = ["wikidot"]
@@ -0,0 +1,57 @@
1
+ """
2
+ Wikidotサイトとの対話を行うためのPythonライブラリ
3
+
4
+ このパッケージはWikidotサイトのAPI操作を抽象化し、直感的なインターフェースを提供する。
5
+ ユーザー、サイト、ページなどのWikidotの主要要素にアクセスするための各種クラスが含まれている。
6
+ """
7
+
8
+ import importlib
9
+ import inspect
10
+ import os
11
+ import sys
12
+
13
+ from .module.client import Client
14
+
15
+ __all__ = ["Client"]
16
+ __version__ = "3.1.0dev11"
17
+
18
+
19
+ # 全クラス・モジュールを公開する
20
+ def _import_submodules():
21
+ """
22
+ パッケージ内の全サブモジュールからクラスをインポートしトップレベルで公開する関数
23
+
24
+ 各サブディレクトリ内のPythonファイルを走査し、含まれるクラスをトップレベルの名前空間に
25
+ インポートする。これにより、`wikidot.ClassName`のような形式でクラスにアクセスできる。
26
+
27
+ Notes
28
+ -----
29
+ '_'で始まるファイル名は無視される。
30
+ インポートに失敗した場合は静かに無視される。
31
+ """
32
+ current_module = sys.modules[__name__]
33
+ package_dir = os.path.dirname(__file__)
34
+
35
+ # 公開対象のディレクトリを走査
36
+ for base_dir in ["common", "connector", "module", "util"]:
37
+ base_path = os.path.join(package_dir, base_dir)
38
+ if not os.path.isdir(base_path):
39
+ continue
40
+
41
+ for filename in os.listdir(base_path):
42
+ if filename.startswith("_") or not filename.endswith(".py"):
43
+ continue
44
+
45
+ module_name = filename[:-3] # .py を除去
46
+ full_module_name = f"{__name__}.{base_dir}.{module_name}"
47
+
48
+ try:
49
+ module = importlib.import_module(full_module_name)
50
+ for name, obj in inspect.getmembers(module, inspect.isclass):
51
+ if obj.__module__ == full_module_name:
52
+ setattr(current_module, name, obj)
53
+ except ImportError:
54
+ pass
55
+
56
+
57
+ _import_submodules()
@@ -0,0 +1,10 @@
1
+ """
2
+ Wikidotライブラリの共通機能モジュール
3
+
4
+ このパッケージは、ライブラリ全体で使用される共通機能を提供する。
5
+ 例外クラス、デコレータ、ロギング機能などの汎用的な機能が含まれる。
6
+ """
7
+
8
+ from .logger import logger as wd_logger
9
+
10
+ __all__ = ["wd_logger"]
@@ -0,0 +1,77 @@
1
+ """
2
+ 各種デコレータを提供するモジュール
3
+
4
+ このモジュールは、ライブラリ内で使用される共通のデコレータを提供する。
5
+ 現在は認証関連のデコレータが実装されている。
6
+ """
7
+
8
+ from functools import wraps
9
+
10
+
11
+ def login_required(func):
12
+ """
13
+ ログインが必要なメソッドや関数に適用するデコレータ
14
+
15
+ このデコレータを適用したメソッドや関数は、実行前に自動的にログイン状態をチェックする。
16
+ ログインしていない場合はLoginRequiredExceptionが送出される。
17
+
18
+ クライアントインスタンスは以下の優先順位で検索される:
19
+ 1. client という名前の引数
20
+ 2. Client クラスのインスタンスである引数
21
+ 3. self.client(呼び出し元オブジェクトの属性)
22
+ 4. selfが持つ属性が持つclientクラス(例:self.site.client)
23
+
24
+ Parameters
25
+ ----------
26
+ func : callable
27
+ デコレートする関数またはメソッド
28
+
29
+ Returns
30
+ -------
31
+ callable
32
+ ラップされた関数またはメソッド
33
+
34
+ Raises
35
+ ------
36
+ ValueError
37
+ クライアントインスタンスが見つからない場合
38
+ LoginRequiredException
39
+ ログインしていない場合(client.login_check()による)
40
+ """
41
+
42
+ @wraps(func)
43
+ def wrapper(*args, **kwargs):
44
+ client = None
45
+ if "client" in kwargs:
46
+ client = kwargs["client"]
47
+ else:
48
+ from wikidot.module.client import Client
49
+
50
+ for arg in args:
51
+ if isinstance(arg, Client):
52
+ client = arg
53
+ break
54
+
55
+ # selfに存在するか?
56
+ if client is None and args:
57
+ if hasattr(args[0], "client"):
58
+ client = args[0].client
59
+ else:
60
+ # selfが持つ属性にclientが存在するか探索する
61
+ for attr_name in dir(args[0]):
62
+ if attr_name.startswith("_"):
63
+ continue
64
+ attr = getattr(args[0], attr_name)
65
+ if hasattr(attr, "client"):
66
+ client = getattr(attr, "client")
67
+ if isinstance(client, Client):
68
+ break
69
+
70
+ if client is None:
71
+ raise ValueError("Client is not found")
72
+
73
+ client.login_check()
74
+
75
+ return func(*args, **kwargs)
76
+
77
+ return wrapper
@@ -0,0 +1,259 @@
1
+ # ---
2
+ # 基底クラス
3
+ # ---
4
+
5
+
6
+ class WikidotException(Exception):
7
+ """
8
+ wikidot.py独自の例外の基底クラス
9
+
10
+ ライブラリ内で発生する全ての例外の親クラスとなる。
11
+ 具体的な例外は各サブクラスで定義される。
12
+
13
+ Parameters
14
+ ----------
15
+ message : str
16
+ 例外メッセージ
17
+ """
18
+
19
+ def __init__(self, message):
20
+ super().__init__(message)
21
+
22
+
23
+ # ---
24
+ # ワイルドカード
25
+ # ---
26
+
27
+
28
+ class UnexpectedException(WikidotException):
29
+ """
30
+ 予期せぬ例外が発生したときに送出される例外
31
+
32
+ 特定のエラー状態に分類できない、予期しない状況で発生する。
33
+ 通常は内部エラーやバグを示す。
34
+
35
+ Parameters
36
+ ----------
37
+ message : str
38
+ 例外メッセージ
39
+ """
40
+
41
+ def __init__(self, message):
42
+ super().__init__(message)
43
+
44
+
45
+ # ---
46
+ # セッション関連
47
+ # ---
48
+
49
+
50
+ class SessionCreateException(WikidotException):
51
+ """
52
+ セッションの作成に失敗したときに送出される例外
53
+
54
+ ログイン処理やセッション確立時に問題が発生した場合に使用される。
55
+ 通常は認証情報の誤りやサーバー側の問題が原因となる。
56
+
57
+ Parameters
58
+ ----------
59
+ message : str
60
+ 例外メッセージ
61
+ """
62
+
63
+ def __init__(self, message):
64
+ super().__init__(message)
65
+
66
+
67
+ class LoginRequiredException(WikidotException):
68
+ """
69
+ ログインが必要なメソッドを未ログイン状態で呼び出したときに送出される例外
70
+
71
+ 認証が必要な操作を実行する前に、ログイン状態をチェックする際に使用される。
72
+
73
+ Parameters
74
+ ----------
75
+ message : str
76
+ 例外メッセージ
77
+ """
78
+
79
+ def __init__(self, message):
80
+ super().__init__(message)
81
+
82
+
83
+ # ---
84
+ # AMC関連
85
+ # ---
86
+ class AjaxModuleConnectorException(WikidotException):
87
+ """
88
+ Ajax Module Connectorへのリクエストに関連する例外の基底クラス
89
+
90
+ ajax-module-connector.phpへのAPIリクエスト処理中に発生する例外の親クラス。
91
+ 具体的なエラー状態は各サブクラスで表現される。
92
+
93
+ Parameters
94
+ ----------
95
+ message : str
96
+ 例外メッセージ
97
+ """
98
+
99
+ def __init__(self, message):
100
+ super().__init__(message)
101
+
102
+
103
+ class AMCHttpStatusCodeException(AjaxModuleConnectorException):
104
+ """
105
+ AMCのHTTPステータスコードが200以外だった場合に送出される例外
106
+
107
+ Ajax Module ConnectorへのリクエストでHTTPレベルのエラーが発生した場合に使用される。
108
+
109
+ Parameters
110
+ ----------
111
+ message : str
112
+ 例外メッセージ
113
+ status_code : int
114
+ エラーとなったHTTPステータスコード
115
+
116
+ Attributes
117
+ ----------
118
+ status_code : int
119
+ エラーとなったHTTPステータスコード
120
+ """
121
+
122
+ def __init__(self, message, status_code: int):
123
+ super().__init__(message)
124
+ self.status_code = status_code
125
+
126
+
127
+ class WikidotStatusCodeException(AjaxModuleConnectorException):
128
+ """
129
+ AMCからのレスポンスのステータスが「ok」でなかった場合に送出される例外
130
+
131
+ HTTP通信自体は成功したが、Wikidot側で処理エラーが発生した場合に使用される。
132
+ HTTPステータスが200以外の場合は代わりにAMCHttpStatusCodeExceptionが使用される。
133
+
134
+ Parameters
135
+ ----------
136
+ message : str
137
+ 例外メッセージ
138
+ status_code : str
139
+ Wikidotから返されたエラーステータスコード
140
+
141
+ Attributes
142
+ ----------
143
+ status_code : str
144
+ Wikidotから返されたエラーステータスコード
145
+ """
146
+
147
+ def __init__(self, message, status_code: str):
148
+ super().__init__(message)
149
+ self.status_code = status_code
150
+
151
+
152
+ class ResponseDataException(AjaxModuleConnectorException):
153
+ """
154
+ AMCからのレスポンスデータが不正だった場合に送出される例外
155
+
156
+ レスポンスのパース失敗や、期待された形式と異なるデータが返された場合に使用される。
157
+
158
+ Parameters
159
+ ----------
160
+ message : str
161
+ 例外メッセージ
162
+ """
163
+
164
+ def __init__(self, message):
165
+ super().__init__(message)
166
+
167
+
168
+ # ---
169
+ # ターゲットエラー関連
170
+ # ---
171
+
172
+
173
+ class NotFoundException(WikidotException):
174
+ """
175
+ 要求されたリソースが見つからない場合に送出される例外
176
+
177
+ サイト、ページ、ユーザー、リビジョンなど、指定されたリソースが
178
+ Wikidot上に存在しない場合に使用される。
179
+
180
+ Parameters
181
+ ----------
182
+ message : str
183
+ 例外メッセージ
184
+ """
185
+
186
+ def __init__(self, message):
187
+ super().__init__(message)
188
+
189
+
190
+ class TargetExistsException(WikidotException):
191
+ """
192
+ 既に存在するリソースを作成しようとした場合に送出される例外
193
+
194
+ 新規作成操作が既存のリソースと衝突する場合に使用される。
195
+
196
+ Parameters
197
+ ----------
198
+ message : str
199
+ 例外メッセージ
200
+ """
201
+
202
+ def __init__(self, message):
203
+ super().__init__(message)
204
+
205
+
206
+ class TargetErrorException(WikidotException):
207
+ """
208
+ 対象オブジェクトに操作を適用できない場合に送出される例外
209
+
210
+ リソースは存在するが、現在の状態では要求された操作を
211
+ 実行できない場合に使用される(例:ロック中のページを編集しようとする)。
212
+
213
+ Parameters
214
+ ----------
215
+ message : str
216
+ 例外メッセージ
217
+ """
218
+
219
+ def __init__(self, message):
220
+ super().__init__(message)
221
+
222
+
223
+ class ForbiddenException(WikidotException):
224
+ """
225
+ 権限不足により操作が拒否された場合に送出される例外
226
+
227
+ ユーザーが操作に必要な権限を持っていない場合や、
228
+ プライベートサイトへのアクセスが拒否された場合などに使用される。
229
+
230
+ Parameters
231
+ ----------
232
+ message : str
233
+ 例外メッセージ
234
+ """
235
+
236
+ def __init__(self, message):
237
+ super().__init__(message)
238
+
239
+
240
+ # ---
241
+ # 処理エラー関連
242
+ # ---
243
+
244
+
245
+ class NoElementException(WikidotException):
246
+ """
247
+ 必要な要素が見つからない場合に送出される例外
248
+
249
+ HTML解析時に期待された要素が見つからない場合など、
250
+ 処理中に必要なデータが欠落している場合に使用される。
251
+
252
+ Parameters
253
+ ----------
254
+ message : str
255
+ 例外メッセージ
256
+ """
257
+
258
+ def __init__(self, message):
259
+ super().__init__(message)
@@ -0,0 +1,43 @@
1
+ """
2
+ ロギング機能を提供するモジュール
3
+
4
+ このモジュールは、ライブラリ全体で使用されるロガーを設定し、提供する。
5
+ ログレベルの設定やフォーマットの指定などが可能。
6
+ """
7
+
8
+ import logging
9
+
10
+
11
+ def setup_logger(name: str = "wikidot", level=logging.INFO):
12
+ """
13
+ ロガーを設定する関数
14
+
15
+ 指定された名前とログレベルでロガーを設定し、適切なフォーマットのハンドラを追加する。
16
+ デフォルトでは、時刻、ロガー名、ログレベル、メッセージを表示する形式となる。
17
+
18
+ Parameters
19
+ ----------
20
+ name : str, default "wikidot"
21
+ ロガーの名前
22
+ level : int, default logging.INFO
23
+ 初期ログレベル
24
+
25
+ Returns
26
+ -------
27
+ logging.Logger
28
+ 設定されたロガーインスタンス
29
+ """
30
+ _logger = logging.getLogger(name)
31
+ _logger.setLevel(level)
32
+
33
+ # ログフォーマット
34
+ formatter = logging.Formatter("%(asctime)s [%(name)s/%(levelname)s] %(message)s")
35
+ stream_handler = logging.StreamHandler()
36
+ stream_handler.setFormatter(formatter)
37
+ _logger.addHandler(stream_handler)
38
+
39
+ return _logger
40
+
41
+
42
+ # パッケージ全体で使用されるデフォルトロガー
43
+ logger = setup_logger()
@@ -0,0 +1,7 @@
1
+ """
2
+ Wikidotサイトとの通信を担当するコネクタモジュール
3
+
4
+ このパッケージは、Wikidot APIおよびAjax機能との通信を行う
5
+ 低レベルなクライアントを提供する。モジュールパッケージのクラスは、
6
+ これらのコネクタを介してWikidotサイトとの通信を行う。
7
+ """