Skip to content

Commit

Permalink
Issue 16071: wordpress requires username, password (#16072)
Browse files Browse the repository at this point in the history
* Issue 16071: wordpress requires username, password

* Adding changes suggested in PR template

* Use Optional typing keyword
  • Loading branch information
jonpspri authored Sep 20, 2024
1 parent a18b946 commit e7a67ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ This loader fetches the text from Wordpress blog posts using the Wordpress API.

## Usage

To use this loader, you need to pass base url of the Wordpress installation (e.g. `https://www.mysite.com`), a username, and an application password for the user (more about application passwords [here](https://www.paidmembershipspro.com/create-application-password-wordpress/))
To use this loader, you need to pass base url of the Wordpress installation
(e.g. `https://www.mysite.com`) and optionally a username, and an application
password for the user (more about application passwords
[here](https://www.paidmembershipspro.com/create-application-password-wordpress/))

```python
from llama_index.readers.wordpress import WordpressReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Wordpress reader."""
import json
from typing import List
from typing import List, Optional

from llama_index.core.readers.base import BaseReader
from llama_index.core.schema import Document
Expand All @@ -13,7 +13,9 @@ class WordpressReader(BaseReader):
wordpress_subdomain (str): Wordpress subdomain
"""

def __init__(self, url: str, password: str, username: str) -> None:
def __init__(
self, url: str, password: Optional[str] = None, username: Optional[str] = None
) -> None:
"""Initialize Wordpress reader."""
self.url = url
self.username = username
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ license = "MIT"
maintainers = ["bbornsztein"]
name = "llama-index-readers-wordpress"
readme = "README.md"
version = "0.2.0"
version = "0.2.1"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
from llama_index.readers.wordpress import WordpressReader


def test_class():
def test_class() -> None:
names_of_base_classes = [b.__name__ for b in WordpressReader.__mro__]
assert BaseReader.__name__ in names_of_base_classes


def test_allow_with_username_and_password() -> None:
wordpress_reader = WordpressReader("http://example.com", "user", "pass")


def test_allow_without_username_and_password() -> None:
wordpress_reader = WordpressReader("http://example.com")

0 comments on commit e7a67ee

Please sign in to comment.