enthusiast-source-wordpress 1.0.1__tar.gz → 1.2.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.
- {enthusiast_source_wordpress-1.0.1 → enthusiast_source_wordpress-1.2.0}/PKG-INFO +5 -5
- {enthusiast_source_wordpress-1.0.1 → enthusiast_source_wordpress-1.2.0}/enthusiast_source_wordpress/source.py +15 -17
- {enthusiast_source_wordpress-1.0.1 → enthusiast_source_wordpress-1.2.0}/pyproject.toml +3 -3
- {enthusiast_source_wordpress-1.0.1 → enthusiast_source_wordpress-1.2.0}/README.md +0 -0
- {enthusiast_source_wordpress-1.0.1 → enthusiast_source_wordpress-1.2.0}/enthusiast_source_wordpress/__init__.py +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: enthusiast-source-wordpress
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A plugin for Enthusiast that provides a Wordpress documents importer.
|
|
5
5
|
Author: Rafal Cymerys
|
|
6
6
|
Author-email: rafal@upsidelab.io
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.10,<4.0
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
10
9
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
-
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Dist: enthusiast-common (>=1.4,<2)
|
|
15
15
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import re
|
|
3
3
|
import urllib.parse
|
|
4
|
-
from typing import Optional
|
|
5
4
|
|
|
6
5
|
import requests
|
|
7
6
|
from enthusiast_common import DocumentDetails, DocumentSourcePlugin
|
|
7
|
+
from enthusiast_common.utils import RequiredFieldsModel
|
|
8
|
+
from pydantic import Field
|
|
8
9
|
from requests import Response
|
|
9
10
|
|
|
10
11
|
logger = logging.getLogger(__name__)
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
class
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
class WordpressConfig(RequiredFieldsModel):
|
|
15
|
+
base_url: str = Field(description="Base URL of the WordPress site")
|
|
16
|
+
user_agent: str = Field(default="", description="Custom User-Agent for requests")
|
|
17
|
+
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
config (dict): configuration of the plugin
|
|
21
|
-
"""
|
|
22
|
-
super().__init__(data_set_id, config)
|
|
19
|
+
class WordpressDocumentSource(DocumentSourcePlugin):
|
|
20
|
+
CONFIGURATION_ARGS = WordpressConfig
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
def __init__(self, data_set_id, **kwargs):
|
|
23
|
+
super().__init__(data_set_id)
|
|
26
24
|
|
|
27
25
|
def fetch(self) -> list[DocumentDetails]:
|
|
28
26
|
session = self._create_http_session()
|
|
@@ -44,19 +42,19 @@ class WordpressDocumentSource(DocumentSourcePlugin):
|
|
|
44
42
|
current_url = self._next_page_link_from_headers(response)
|
|
45
43
|
return results
|
|
46
44
|
|
|
47
|
-
def _next_page_link_from_headers(self, response: Response) ->
|
|
45
|
+
def _next_page_link_from_headers(self, response: Response) -> str:
|
|
48
46
|
link_header = response.headers["Link"]
|
|
49
47
|
|
|
50
48
|
match = re.search(r'<(\S+?)>; rel="next"', link_header)
|
|
51
49
|
if match:
|
|
52
50
|
return match.group(1)
|
|
53
|
-
return
|
|
51
|
+
return ""
|
|
54
52
|
|
|
55
53
|
def _posts_url(self):
|
|
56
|
-
return urllib.parse.urljoin(self.
|
|
54
|
+
return urllib.parse.urljoin(self.CONFIGURATION_ARGS.base_url, "wp-json/wp/v2/posts")
|
|
57
55
|
|
|
58
56
|
def _create_http_session(self):
|
|
59
57
|
session = requests.Session()
|
|
60
|
-
if self.
|
|
61
|
-
session.headers.update({"User-Agent": self.
|
|
58
|
+
if self.CONFIGURATION_ARGS.user_agent:
|
|
59
|
+
session.headers.update({"User-Agent": self.CONFIGURATION_ARGS.user_agent})
|
|
62
60
|
return session
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "enthusiast-source-wordpress"
|
|
3
|
-
version = "1.0
|
|
3
|
+
version = "1.2.0"
|
|
4
4
|
description = "A plugin for Enthusiast that provides a Wordpress documents importer."
|
|
5
5
|
authors = ["Rafal Cymerys <rafal@upsidelab.io>"]
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
|
|
8
8
|
[tool.poetry.dependencies]
|
|
9
|
-
python = "^3.
|
|
10
|
-
enthusiast-common = ">=1,<2"
|
|
9
|
+
python = "^3.10"
|
|
10
|
+
enthusiast-common = ">=1.4,<2"
|
|
11
11
|
requests = "^2.32.3"
|
|
12
12
|
|
|
13
13
|
|
|
File without changes
|
|
File without changes
|