enthusiast-source-wordpress 0.1.1__tar.gz → 0.1.2__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: enthusiast-source-wordpress
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary:
5
5
  Author: Rafal Cymerys
6
6
  Author-email: rafal@upsidelab.io
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3.9
10
10
  Classifier: Programming Language :: Python :: 3.10
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
13
14
  Requires-Dist: enthusiast-common (>=0.2,<1)
14
15
  Requires-Dist: requests (>=2.32.3,<3.0.0)
15
16
  Description-Content-Type: text/markdown
@@ -1 +1 @@
1
- from .source import WordpressDocumentSource as WordpressDocumentSource
1
+ from .source import WordpressDocumentSource as WordpressDocumentSource
@@ -9,6 +9,7 @@ from requests import Response
9
9
 
10
10
  logger = logging.getLogger(__name__)
11
11
 
12
+
12
13
  class WordpressDocumentSource(DocumentSourcePlugin):
13
14
  def __init__(self, data_set_id, config: dict):
14
15
  """
@@ -32,19 +33,19 @@ class WordpressDocumentSource(DocumentSourcePlugin):
32
33
  logger.info(f"Fetching {current_url}")
33
34
  response = session.get(current_url)
34
35
  posts = response.json()
35
- results.extend([
36
- DocumentDetails(
37
- url=post['link'],
38
- title=post['title']['rendered'],
39
- content=post['content']['rendered']
40
- )
41
- for post in posts
42
- ])
36
+ results.extend(
37
+ [
38
+ DocumentDetails(
39
+ url=post["link"], title=post["title"]["rendered"], content=post["content"]["rendered"]
40
+ )
41
+ for post in posts
42
+ ]
43
+ )
43
44
  current_url = self._next_page_link_from_headers(response)
44
45
  return results
45
46
 
46
47
  def _next_page_link_from_headers(self, response: Response) -> Optional[str]:
47
- link_header = response.headers['Link']
48
+ link_header = response.headers["Link"]
48
49
 
49
50
  match = re.search(r'<(\S+?)>; rel="next"', link_header)
50
51
  if match:
@@ -52,10 +53,10 @@ class WordpressDocumentSource(DocumentSourcePlugin):
52
53
  return None
53
54
 
54
55
  def _posts_url(self):
55
- return urllib.parse.urljoin(self._wordpress_url, 'wp-json/wp/v2/posts')
56
+ return urllib.parse.urljoin(self._wordpress_url, "wp-json/wp/v2/posts")
56
57
 
57
58
  def _create_http_session(self):
58
59
  session = requests.Session()
59
60
  if self._user_agent:
60
- session.headers.update({'User-Agent': self._user_agent})
61
+ session.headers.update({"User-Agent": self._user_agent})
61
62
  return session
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "enthusiast-source-wordpress"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = ""
5
5
  authors = ["Rafal Cymerys <rafal@upsidelab.io>"]
6
6
  readme = "README.md"