-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a654a05
commit 74f2e62
Showing
4 changed files
with
19 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,36 @@ | ||
|
||
class ConfluenceDocument: | ||
def __init__(self, metadata, page_content, deleted=False): | ||
def __init__(self, metadata, data, deleted=False): | ||
""" | ||
Initializes a ConfluenceDocument instance. | ||
:param metadata: A dictionary containing metadata about the Confluence document. | ||
Expected to contain 'title', 'id', and 'source'. | ||
:param page_content: A string representing the content of the Confluence page. | ||
:param deleted: A boolean indicating whether the document is considered deleted. | ||
'deleted' key will be added to indicate if the document is considered deleted. | ||
:param data: A string representing the content of the Confluence page. | ||
""" | ||
self.validate_metadata(metadata) | ||
metadata['deleted'] = deleted | ||
self.metadata = metadata | ||
self.page_content = page_content | ||
self.deleted = deleted | ||
self.data = data | ||
|
||
def serialize(self): | ||
""" | ||
Serializes the ConfluenceDocument instance into a dictionary. | ||
""" | ||
return { | ||
'metadata': self.metadata, | ||
'page_content': self.page_content, | ||
'deleted': self.deleted | ||
'data': self.data | ||
} | ||
|
||
@staticmethod | ||
def validate_metadata(metadata): | ||
""" | ||
Validates the metadata dictionary to ensure it contains required keys. | ||
Validates the metadata dictionary to ensure it contains required keys plus checks for 'deleted'. | ||
:param metadata: A dictionary containing metadata about the Confluence document. | ||
:raises ValueError: If metadata does not contain the required keys. | ||
:raises ValueError: If metadata does not contain the required keys ('title', 'id', 'source'). | ||
""" | ||
required_keys = {'title', 'id', 'source'} | ||
if not required_keys.issubset(metadata): | ||
missing_keys = required_keys - metadata.keys() | ||
raise ValueError(f"Metadata is missing required keys: {missing_keys}") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters