-
Notifications
You must be signed in to change notification settings - Fork 162
feat: adding support for output to litara #897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+521
−9
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,55 @@ | ||
| """Helpers for Litara settings validation and connection tests.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from shelfmark.core.config import config | ||
| from shelfmark.core.logger import setup_logger | ||
| from shelfmark.download.outputs.litara import ( | ||
| LitaraConfig, | ||
| LitaraError, | ||
| litara_login, | ||
| ) | ||
|
|
||
| logger = setup_logger(__name__) | ||
|
|
||
|
|
||
| def check_litara_connection( | ||
| current_values: dict[str, Any] | None = None, | ||
| ) -> dict[str, Any]: | ||
| """Test the Litara connection using current form values.""" | ||
| current_values = current_values or {} | ||
|
|
||
| def _get_value(key: str, default: object = None) -> object: | ||
| value = current_values.get(key) | ||
| if value not in (None, ""): | ||
| return value | ||
| if default is None: | ||
| return config.get(key) | ||
| return config.get(key, default) | ||
|
|
||
| base_url = str(_get_value("LITARA_HOST", "") or "").strip().rstrip("/") | ||
| email = str(_get_value("LITARA_EMAIL", "") or "").strip() | ||
| password = str(_get_value("LITARA_PASSWORD", "") or "") | ||
|
|
||
| if not base_url: | ||
| return {"success": False, "message": "Litara URL is required"} | ||
| if not email: | ||
| return {"success": False, "message": "Litara email is required"} | ||
| if not password: | ||
| return {"success": False, "message": "Litara password is required"} | ||
|
|
||
| litara_config = LitaraConfig( | ||
| base_url=base_url, | ||
| email=email, | ||
| password=password, | ||
| verify_tls=True, | ||
| ) | ||
|
|
||
| try: | ||
| litara_login(litara_config) | ||
| except LitaraError as exc: | ||
| return {"success": False, "message": str(exc)} | ||
| else: | ||
| return {"success": True, "message": "Connected to Litara"} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output-mode option description says "Upload files directly to Litara", but this integration uploads to Litara Book Drop (admin approval flow) rather than directly into a library. Updating this description to explicitly mention Book Drop will prevent user confusion and better match the behavior/heading text below.