python-loading-sdk 0.4.0__tar.gz → 0.5.0__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 (33) hide show
  1. python_loading_sdk-0.5.0/PKG-INFO +185 -0
  2. python_loading_sdk-0.5.0/README.md +163 -0
  3. python_loading_sdk-0.5.0/pyproject.toml +80 -0
  4. python_loading_sdk-0.5.0/pyproject.toml.orig +57 -0
  5. python_loading_sdk-0.5.0/src/loading_sdk/_api.py +254 -0
  6. python_loading_sdk-0.5.0/src/loading_sdk/_http.py +47 -0
  7. python_loading_sdk-0.5.0/src/loading_sdk/_parsing.py +70 -0
  8. python_loading_sdk-0.5.0/src/loading_sdk/async_api/client.py +268 -0
  9. python_loading_sdk-0.5.0/src/loading_sdk/async_api/extractors.py +70 -0
  10. python_loading_sdk-0.5.0/src/loading_sdk/sync_api/client.py +248 -0
  11. python_loading_sdk-0.5.0/src/loading_sdk/sync_api/extractors.py +70 -0
  12. python_loading_sdk-0.5.0/tests/__init__.py +0 -0
  13. python_loading_sdk-0.5.0/tests/fixtures/README.md +5 -0
  14. python_loading_sdk-0.5.0/tests/fixtures/editorial.json +16 -0
  15. python_loading_sdk-0.5.0/tests/fixtures/footer.js +2 -0
  16. python_loading_sdk-0.5.0/tests/fixtures/loading.html +1 -0
  17. {python-loading-sdk-0.4.0 → python_loading_sdk-0.5.0}/tests/test_api.py +239 -284
  18. python_loading_sdk-0.5.0/tests/test_client_behavior.py +148 -0
  19. python_loading_sdk-0.5.0/tests/test_httpx_runtime.py +220 -0
  20. python-loading-sdk-0.4.0/PKG-INFO +0 -127
  21. python-loading-sdk-0.4.0/README.md +0 -106
  22. python-loading-sdk-0.4.0/loading_sdk/async_api/client.py +0 -598
  23. python-loading-sdk-0.4.0/loading_sdk/async_api/extractors.py +0 -132
  24. python-loading-sdk-0.4.0/loading_sdk/sync_api/client.py +0 -565
  25. python-loading-sdk-0.4.0/loading_sdk/sync_api/extractors.py +0 -132
  26. python-loading-sdk-0.4.0/pyproject.toml +0 -29
  27. python-loading-sdk-0.4.0/setup.py +0 -32
  28. {python-loading-sdk-0.4.0 → python_loading_sdk-0.5.0}/LICENSE.md +0 -0
  29. {python-loading-sdk-0.4.0 → python_loading_sdk-0.5.0/src}/loading_sdk/__init__.py +1 -1
  30. {python-loading-sdk-0.4.0 → python_loading_sdk-0.5.0/src}/loading_sdk/async_api/__init__.py +0 -0
  31. /python-loading-sdk-0.4.0/tests/__init__.py → /python_loading_sdk-0.5.0/src/loading_sdk/py.typed +0 -0
  32. {python-loading-sdk-0.4.0 → python_loading_sdk-0.5.0/src}/loading_sdk/settings.py +0 -0
  33. {python-loading-sdk-0.4.0 → python_loading_sdk-0.5.0/src}/loading_sdk/sync_api/__init__.py +0 -0
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-loading-sdk
3
+ Version: 0.5.0
4
+ Summary: Synchronous and asynchronous Python clients for Loading.se
5
+ Author: hnrkcode
6
+ Author-email: hnrkcode <44243358+hnrkcode@users.noreply.github.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE.md
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Requires-Dist: httpx>=0.28.1,<0.29
16
+ Requires-Dist: beautifulsoup4>=4.15,<5
17
+ Requires-Python: >=3.11
18
+ Project-URL: Repository, https://github.com/hnrkcode/python-loading-sdk
19
+ Project-URL: Changelog, https://github.com/hnrkcode/python-loading-sdk/blob/main/CHANGELOG.md
20
+ Project-URL: Issues, https://github.com/hnrkcode/python-loading-sdk/issues
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Python Loading SDK
24
+
25
+ [![PyPI Version][pypi-image]][pypi-url]
26
+ [![Supported Python versions][versions-image]][versions-url]
27
+ [![Build Status][build-image]][build-url]
28
+
29
+ [pypi-image]: https://img.shields.io/pypi/v/python-loading-sdk
30
+ [pypi-url]: https://pypi.org/project/python-loading-sdk/
31
+ [versions-image]: https://img.shields.io/pypi/pyversions/python-loading-sdk
32
+ [versions-url]: https://pypi.org/project/python-loading-sdk/
33
+ [build-image]: https://github.com/hnrkcode/python-loading-sdk/actions/workflows/build.yaml/badge.svg
34
+ [build-url]: https://github.com/hnrkcode/python-loading-sdk/actions/workflows/build.yaml
35
+
36
+ Access the Loading.se forums and editorial content from synchronous or asynchronous Python code.
37
+
38
+ ## Install
39
+
40
+ Requires Python 3.11 or newer.
41
+
42
+ ```
43
+ pip install python-loading-sdk
44
+ ```
45
+
46
+ See the [release notes](https://github.com/hnrkcode/python-loading-sdk/blob/main/CHANGELOG.md) for Python support and HTTP behavior changes.
47
+
48
+ ## Usage
49
+
50
+ Create a client without credentials to read public content. Provide credentials to access your profile or create and edit posts.
51
+
52
+ ```python
53
+ from loading_sdk import LoadingApiClient
54
+
55
+ client = LoadingApiClient(email="your@email.com", password="your_password")
56
+
57
+ response = client.get_profile()
58
+ ```
59
+
60
+ The async factory is awaitable.
61
+
62
+ ```python
63
+ from loading_sdk import AsyncLoadingApiClient
64
+
65
+ client = await AsyncLoadingApiClient(email="your@email.com", password="your_password")
66
+
67
+ response = await client.get_profile()
68
+ ```
69
+
70
+ ### Connection ownership and errors
71
+
72
+ Ordinary calls open and close a temporary HTTPX client for each SDK operation. Pagination and extraction reuse that connection pool across their requests. Login cookies stay with the SDK instance between operations.
73
+
74
+ A context manager shares one pool across multiple operations.
75
+
76
+ ```python
77
+ with LoadingApiClient() as client:
78
+ games = client.get_games()
79
+ socials = client.get_socials()
80
+
81
+ async with await AsyncLoadingApiClient() as client:
82
+ games = await client.get_games()
83
+ socials = await client.get_socials()
84
+ ```
85
+
86
+ Both factories accept a keyword-only `transport` for custom HTTPX transports, including `httpx.MockTransport`. Supplying a transport gives the SDK ownership and enables pooling immediately. Use the context manager or call `close()` / `await aclose()` to release it. Each SDK instance needs its own transport.
87
+
88
+ The SDK follows redirects. It sends login cookies only on authenticated API calls, respecting the API origin and cookie domain, path, and security attributes. A redirect that would replay an authenticated form to another origin raises `httpx.RequestError`.
89
+
90
+ Sync requests default to a 10-second timeout per network phase. Async requests default to a 300-second total deadline per request, including redirects, with a 30-second connection timeout. Set `timeout` in seconds on either factory to change the deadline or phase limit. Network failures propagate as HTTPX exceptions, including `httpx.TimeoutException` and `httpx.ConnectError`. API error responses retain their SDK dictionary format.
91
+
92
+ ## Examples
93
+
94
+ ### Requires Auth
95
+
96
+ ```python
97
+ response = client.get_profile()
98
+ ```
99
+
100
+ ```python
101
+ response = client.create_post(
102
+ thread_id="5bbb986af1deda001d33bc4b", message="My message!"
103
+ )
104
+ ```
105
+
106
+ ```python
107
+ response = client.edit_post(
108
+ post_id="5bc876dd70a79c001dab7ebe", message="My updated message!"
109
+ )
110
+ ```
111
+
112
+ ```python
113
+ response = client.create_thread(
114
+ title="My title", message="The content!", category_name="games"
115
+ )
116
+ ```
117
+
118
+ ```python
119
+ response = client.edit_thread(
120
+ thread_id="5bbb986af1deda001d33bc4b", message="My updated message!"
121
+ )
122
+ ```
123
+
124
+ ### Anonymous
125
+
126
+ ```python
127
+ response = client.search(query="search query")
128
+ ```
129
+
130
+ ```python
131
+ response = client.get_post(post_id="5bc876dd70a79c001dab7ebe")
132
+ ```
133
+
134
+ ```python
135
+ response = client.get_thread(thread_id="5bbb986af1deda001d33bc4b", page=3)
136
+ ```
137
+
138
+ ```python
139
+ response = client.get_games(page=5)
140
+ ```
141
+
142
+ ```python
143
+ response = client.get_other(page=7)
144
+ ```
145
+
146
+ ```python
147
+ response = client.get_editorials(page=2, post_type="review", sort="title")
148
+ ```
149
+
150
+ ```python
151
+ response = client.get_about()
152
+ ```
153
+
154
+ ```python
155
+ response = client.get_socials()
156
+ ```
157
+
158
+ ```python
159
+ response = client.get_total_thread_pages(thread_id="5bbb986af1deda001d33bc4b")
160
+ ```
161
+
162
+ ```python
163
+ response = client.get_total_category_pages(category="games")
164
+ ```
165
+
166
+ ## Development
167
+
168
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/) and run these commands from the checkout. The project defaults to Python 3.13.
169
+
170
+ ```sh
171
+ uv sync --locked
172
+ uv run ruff format --check .
173
+ uv run ruff check .
174
+ uv run ty check
175
+ uv run pytest --cov=loading_sdk --cov-branch
176
+ uv build
177
+ ```
178
+
179
+ The SDK lives in `src/loading_sdk/`. The build produces a wheel and source distribution in `dist/`. To build the documentation, run `uv run --locked --group docs sphinx-build -b html docs/source docs/build/html`.
180
+
181
+ ### Publishing a release
182
+
183
+ Set the project version with `uv version`, commit the updated metadata and lockfile, and push a matching `v<version>` tag. A prerelease tag such as `v0.5.0rc1` targets TestPyPI. After its index verification succeeds, a stable tag such as `v0.5.0` targets PyPI.
184
+
185
+ Configure a GitHub Trusted Publisher on each index for `hnrkcode/python-loading-sdk`, workflow `pypi.yaml`, and the corresponding GitHub environment (`testpypi` or `pypi`). The workflow checks the distributions, uploads the verified files, and installs both downloads from the target index.
@@ -0,0 +1,163 @@
1
+ # Python Loading SDK
2
+
3
+ [![PyPI Version][pypi-image]][pypi-url]
4
+ [![Supported Python versions][versions-image]][versions-url]
5
+ [![Build Status][build-image]][build-url]
6
+
7
+ [pypi-image]: https://img.shields.io/pypi/v/python-loading-sdk
8
+ [pypi-url]: https://pypi.org/project/python-loading-sdk/
9
+ [versions-image]: https://img.shields.io/pypi/pyversions/python-loading-sdk
10
+ [versions-url]: https://pypi.org/project/python-loading-sdk/
11
+ [build-image]: https://github.com/hnrkcode/python-loading-sdk/actions/workflows/build.yaml/badge.svg
12
+ [build-url]: https://github.com/hnrkcode/python-loading-sdk/actions/workflows/build.yaml
13
+
14
+ Access the Loading.se forums and editorial content from synchronous or asynchronous Python code.
15
+
16
+ ## Install
17
+
18
+ Requires Python 3.11 or newer.
19
+
20
+ ```
21
+ pip install python-loading-sdk
22
+ ```
23
+
24
+ See the [release notes](https://github.com/hnrkcode/python-loading-sdk/blob/main/CHANGELOG.md) for Python support and HTTP behavior changes.
25
+
26
+ ## Usage
27
+
28
+ Create a client without credentials to read public content. Provide credentials to access your profile or create and edit posts.
29
+
30
+ ```python
31
+ from loading_sdk import LoadingApiClient
32
+
33
+ client = LoadingApiClient(email="your@email.com", password="your_password")
34
+
35
+ response = client.get_profile()
36
+ ```
37
+
38
+ The async factory is awaitable.
39
+
40
+ ```python
41
+ from loading_sdk import AsyncLoadingApiClient
42
+
43
+ client = await AsyncLoadingApiClient(email="your@email.com", password="your_password")
44
+
45
+ response = await client.get_profile()
46
+ ```
47
+
48
+ ### Connection ownership and errors
49
+
50
+ Ordinary calls open and close a temporary HTTPX client for each SDK operation. Pagination and extraction reuse that connection pool across their requests. Login cookies stay with the SDK instance between operations.
51
+
52
+ A context manager shares one pool across multiple operations.
53
+
54
+ ```python
55
+ with LoadingApiClient() as client:
56
+ games = client.get_games()
57
+ socials = client.get_socials()
58
+
59
+ async with await AsyncLoadingApiClient() as client:
60
+ games = await client.get_games()
61
+ socials = await client.get_socials()
62
+ ```
63
+
64
+ Both factories accept a keyword-only `transport` for custom HTTPX transports, including `httpx.MockTransport`. Supplying a transport gives the SDK ownership and enables pooling immediately. Use the context manager or call `close()` / `await aclose()` to release it. Each SDK instance needs its own transport.
65
+
66
+ The SDK follows redirects. It sends login cookies only on authenticated API calls, respecting the API origin and cookie domain, path, and security attributes. A redirect that would replay an authenticated form to another origin raises `httpx.RequestError`.
67
+
68
+ Sync requests default to a 10-second timeout per network phase. Async requests default to a 300-second total deadline per request, including redirects, with a 30-second connection timeout. Set `timeout` in seconds on either factory to change the deadline or phase limit. Network failures propagate as HTTPX exceptions, including `httpx.TimeoutException` and `httpx.ConnectError`. API error responses retain their SDK dictionary format.
69
+
70
+ ## Examples
71
+
72
+ ### Requires Auth
73
+
74
+ ```python
75
+ response = client.get_profile()
76
+ ```
77
+
78
+ ```python
79
+ response = client.create_post(
80
+ thread_id="5bbb986af1deda001d33bc4b", message="My message!"
81
+ )
82
+ ```
83
+
84
+ ```python
85
+ response = client.edit_post(
86
+ post_id="5bc876dd70a79c001dab7ebe", message="My updated message!"
87
+ )
88
+ ```
89
+
90
+ ```python
91
+ response = client.create_thread(
92
+ title="My title", message="The content!", category_name="games"
93
+ )
94
+ ```
95
+
96
+ ```python
97
+ response = client.edit_thread(
98
+ thread_id="5bbb986af1deda001d33bc4b", message="My updated message!"
99
+ )
100
+ ```
101
+
102
+ ### Anonymous
103
+
104
+ ```python
105
+ response = client.search(query="search query")
106
+ ```
107
+
108
+ ```python
109
+ response = client.get_post(post_id="5bc876dd70a79c001dab7ebe")
110
+ ```
111
+
112
+ ```python
113
+ response = client.get_thread(thread_id="5bbb986af1deda001d33bc4b", page=3)
114
+ ```
115
+
116
+ ```python
117
+ response = client.get_games(page=5)
118
+ ```
119
+
120
+ ```python
121
+ response = client.get_other(page=7)
122
+ ```
123
+
124
+ ```python
125
+ response = client.get_editorials(page=2, post_type="review", sort="title")
126
+ ```
127
+
128
+ ```python
129
+ response = client.get_about()
130
+ ```
131
+
132
+ ```python
133
+ response = client.get_socials()
134
+ ```
135
+
136
+ ```python
137
+ response = client.get_total_thread_pages(thread_id="5bbb986af1deda001d33bc4b")
138
+ ```
139
+
140
+ ```python
141
+ response = client.get_total_category_pages(category="games")
142
+ ```
143
+
144
+ ## Development
145
+
146
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/) and run these commands from the checkout. The project defaults to Python 3.13.
147
+
148
+ ```sh
149
+ uv sync --locked
150
+ uv run ruff format --check .
151
+ uv run ruff check .
152
+ uv run ty check
153
+ uv run pytest --cov=loading_sdk --cov-branch
154
+ uv build
155
+ ```
156
+
157
+ The SDK lives in `src/loading_sdk/`. The build produces a wheel and source distribution in `dist/`. To build the documentation, run `uv run --locked --group docs sphinx-build -b html docs/source docs/build/html`.
158
+
159
+ ### Publishing a release
160
+
161
+ Set the project version with `uv version`, commit the updated metadata and lockfile, and push a matching `v<version>` tag. A prerelease tag such as `v0.5.0rc1` targets TestPyPI. After its index verification succeeds, a stable tag such as `v0.5.0` targets PyPI.
162
+
163
+ Configure a GitHub Trusted Publisher on each index for `hnrkcode/python-loading-sdk`, workflow `pypi.yaml`, and the corresponding GitHub environment (`testpypi` or `pypi`). The workflow checks the distributions, uploads the verified files, and installs both downloads from the target index.
@@ -0,0 +1,80 @@
1
+ [project]
2
+ name = "python-loading-sdk"
3
+ version = "0.5.0"
4
+ description = "Synchronous and asynchronous Python clients for Loading.se"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE.md"]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3 :: Only",
11
+ "Programming Language :: Python :: 3.11",
12
+ "Programming Language :: Python :: 3.12",
13
+ "Programming Language :: Python :: 3.13",
14
+ "Programming Language :: Python :: 3.14",
15
+ "Programming Language :: Python :: 3.15",
16
+ ]
17
+ dependencies = [
18
+ "httpx>=0.28.1,<0.29",
19
+ "beautifulsoup4>=4.15,<5",
20
+ ]
21
+
22
+ [[project.authors]]
23
+ name = "hnrkcode"
24
+ email = "44243358+hnrkcode@users.noreply.github.com"
25
+
26
+ [project.urls]
27
+ Repository = "https://github.com/hnrkcode/python-loading-sdk"
28
+ Changelog = "https://github.com/hnrkcode/python-loading-sdk/blob/main/CHANGELOG.md"
29
+ Issues = "https://github.com/hnrkcode/python-loading-sdk/issues"
30
+
31
+ [dependency-groups]
32
+ lint = [
33
+ "ruff",
34
+ "ty",
35
+ ]
36
+ test = [
37
+ "pytest",
38
+ "pytest-asyncio",
39
+ "pytest-cov",
40
+ "pytest-httpserver",
41
+ ]
42
+ docs = [
43
+ "sphinx>=9",
44
+ "sphinx-rtd-theme>=3.1",
45
+ ]
46
+ release = ["twine>=6"]
47
+
48
+ [[dependency-groups.dev]]
49
+ include-group = "lint"
50
+
51
+ [[dependency-groups.dev]]
52
+ include-group = "test"
53
+
54
+ [build-system]
55
+ requires = ["uv_build>=0.13.9,<0.14"]
56
+ build-backend = "uv_build"
57
+
58
+ [tool.uv.build-backend]
59
+ module-name = "loading_sdk"
60
+ source-include = [
61
+ "tests/**/*.py",
62
+ "tests/fixtures/*",
63
+ ]
64
+
65
+ [tool.ruff.lint]
66
+ select = [
67
+ "E4",
68
+ "E7",
69
+ "E9",
70
+ "F",
71
+ "I",
72
+ "B",
73
+ "C90",
74
+ "UP",
75
+ ]
76
+
77
+ [tool.pytest.ini_options]
78
+ testpaths = ["tests"]
79
+ asyncio_mode = "strict"
80
+ asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1,57 @@
1
+ [project]
2
+ name = "python-loading-sdk"
3
+ version = "0.5.0"
4
+ description = "Synchronous and asynchronous Python clients for Loading.se"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE.md"]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3 :: Only",
11
+ "Programming Language :: Python :: 3.11",
12
+ "Programming Language :: Python :: 3.12",
13
+ "Programming Language :: Python :: 3.13",
14
+ "Programming Language :: Python :: 3.14",
15
+ "Programming Language :: Python :: 3.15",
16
+ ]
17
+ authors = [
18
+ { name = "hnrkcode", email = "44243358+hnrkcode@users.noreply.github.com" },
19
+ ]
20
+ dependencies = [
21
+ "httpx>=0.28.1,<0.29",
22
+ "beautifulsoup4>=4.15,<5",
23
+ ]
24
+
25
+ [project.urls]
26
+ Repository = "https://github.com/hnrkcode/python-loading-sdk"
27
+ Changelog = "https://github.com/hnrkcode/python-loading-sdk/blob/main/CHANGELOG.md"
28
+ Issues = "https://github.com/hnrkcode/python-loading-sdk/issues"
29
+
30
+ [dependency-groups]
31
+ dev = [
32
+ { include-group = "lint" },
33
+ { include-group = "test" },
34
+ ]
35
+ lint = ["ruff", "ty"]
36
+ test = ["pytest", "pytest-asyncio", "pytest-cov", "pytest-httpserver"]
37
+ docs = [
38
+ "sphinx>=9",
39
+ "sphinx-rtd-theme>=3.1",
40
+ ]
41
+ release = ["twine>=6"]
42
+
43
+ [build-system]
44
+ requires = ["uv_build>=0.13.9,<0.14"]
45
+ build-backend = "uv_build"
46
+
47
+ [tool.uv.build-backend]
48
+ module-name = "loading_sdk"
49
+ source-include = ["tests/**/*.py", "tests/fixtures/*"]
50
+
51
+ [tool.ruff.lint]
52
+ select = ["E4", "E7", "E9", "F", "I", "B", "C90", "UP"]
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ asyncio_mode = "strict"
57
+ asyncio_default_fixture_loop_scope = "function"