karakeep-python-api 1.3.1__tar.gz → 1.4.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.
- {karakeep_python_api-1.3.1/karakeep_python_api.egg-info → karakeep_python_api-1.4.0}/PKG-INFO +1 -1
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api/__main__.py +127 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api/karakeep_api.py +1 -1
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0/karakeep_python_api.egg-info}/PKG-INFO +1 -1
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/setup.py +1 -1
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/LICENSE +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/MANIFEST.in +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/README.md +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api/__init__.py +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api/datatypes.py +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api/openapi_reference.json +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/SOURCES.txt +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/dependency_links.txt +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/entry_points.txt +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/requires.txt +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/top_level.txt +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/setup.cfg +0 -0
- {karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/tests/test_karakeep_api.py +0 -0
|
@@ -409,6 +409,116 @@ def create_click_command(
|
|
|
409
409
|
break
|
|
410
410
|
|
|
411
411
|
result = all_bookmarks_data # This will be a list of Bookmark models or dicts
|
|
412
|
+
elif method_name == "get_all_highlights":
|
|
413
|
+
logger.debug(
|
|
414
|
+
f"Special CLI pagination handling for '{method_name}'."
|
|
415
|
+
)
|
|
416
|
+
cli_total_limit = call_args.pop("limit", None)
|
|
417
|
+
|
|
418
|
+
call_args.pop("cursor", None) # Ignore CLI cursor
|
|
419
|
+
|
|
420
|
+
all_highlights_data = []
|
|
421
|
+
current_page_api_cursor = None
|
|
422
|
+
fetched_count = 0
|
|
423
|
+
API_INTERNAL_PAGE_SIZE = 50 # Define a page size for API calls
|
|
424
|
+
|
|
425
|
+
while True:
|
|
426
|
+
api_call_limit = API_INTERNAL_PAGE_SIZE
|
|
427
|
+
if cli_total_limit is not None:
|
|
428
|
+
remaining_needed = cli_total_limit - fetched_count
|
|
429
|
+
if remaining_needed <= 0:
|
|
430
|
+
break # Reached or exceeded CLI total limit
|
|
431
|
+
api_call_limit = min(
|
|
432
|
+
API_INTERNAL_PAGE_SIZE, remaining_needed
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
if (
|
|
436
|
+
api_call_limit <= 0 and cli_total_limit is not None
|
|
437
|
+
): # Avoid asking for 0 or negative items unless fetching all
|
|
438
|
+
break
|
|
439
|
+
|
|
440
|
+
logger.debug(
|
|
441
|
+
f"Fetching page for '{method_name}' with cursor: {current_page_api_cursor}, api_limit: {api_call_limit}"
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
page_call_args = {
|
|
445
|
+
"limit": api_call_limit,
|
|
446
|
+
"cursor": current_page_api_cursor,
|
|
447
|
+
}
|
|
448
|
+
page_call_args_filtered = {
|
|
449
|
+
k: v for k, v in page_call_args.items() if v is not None
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
try:
|
|
453
|
+
page_result_obj = instance_method(
|
|
454
|
+
**page_call_args_filtered
|
|
455
|
+
)
|
|
456
|
+
except TypeError as call_error_page:
|
|
457
|
+
logger.error(
|
|
458
|
+
f"Error calling API method '{method_name}' (paginated): {call_error_page}"
|
|
459
|
+
)
|
|
460
|
+
logger.error(
|
|
461
|
+
f"Provided arguments for page: {page_call_args_filtered}"
|
|
462
|
+
)
|
|
463
|
+
if verbose:
|
|
464
|
+
logger.debug(traceback.format_exc())
|
|
465
|
+
ctx.exit(1)
|
|
466
|
+
|
|
467
|
+
highlights_on_this_page = []
|
|
468
|
+
next_api_cursor = None
|
|
469
|
+
|
|
470
|
+
# Convert Pydantic model to dict using model_dump if available
|
|
471
|
+
if hasattr(page_result_obj, "model_dump"):
|
|
472
|
+
result_dict = page_result_obj.model_dump()
|
|
473
|
+
elif isinstance(page_result_obj, dict):
|
|
474
|
+
result_dict = page_result_obj
|
|
475
|
+
else:
|
|
476
|
+
logger.warning(
|
|
477
|
+
f"Unexpected result type: {type(page_result_obj)}"
|
|
478
|
+
)
|
|
479
|
+
result_dict = {}
|
|
480
|
+
|
|
481
|
+
# Extract data and cursor from the dict
|
|
482
|
+
highlights_on_this_page = result_dict.get("highlights", [])
|
|
483
|
+
next_api_cursor = result_dict.get("nextCursor")
|
|
484
|
+
|
|
485
|
+
logger.debug(
|
|
486
|
+
f"Extracted {len(highlights_on_this_page)} highlights and cursor: {next_api_cursor}"
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
if not isinstance(highlights_on_this_page, list):
|
|
490
|
+
logger.warning(
|
|
491
|
+
f"Expected a list of highlights, got {type(highlights_on_this_page)}. Stopping pagination."
|
|
492
|
+
)
|
|
493
|
+
break
|
|
494
|
+
|
|
495
|
+
all_highlights_data.extend(highlights_on_this_page)
|
|
496
|
+
fetched_count += len(highlights_on_this_page)
|
|
497
|
+
logger.debug(
|
|
498
|
+
f"Fetched {len(highlights_on_this_page)} highlights this page. Total fetched: {fetched_count}."
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
current_page_api_cursor = next_api_cursor
|
|
502
|
+
if not current_page_api_cursor:
|
|
503
|
+
logger.debug(
|
|
504
|
+
"No nextCursor from API, pagination complete."
|
|
505
|
+
)
|
|
506
|
+
break
|
|
507
|
+
if (
|
|
508
|
+
cli_total_limit is not None
|
|
509
|
+
and fetched_count >= cli_total_limit
|
|
510
|
+
):
|
|
511
|
+
logger.debug(
|
|
512
|
+
f"CLI total limit of {cli_total_limit} reached or exceeded."
|
|
513
|
+
)
|
|
514
|
+
break
|
|
515
|
+
if not highlights_on_this_page and api_call_limit > 0:
|
|
516
|
+
logger.debug(
|
|
517
|
+
"API returned an empty list of highlights while a positive limit was set, assuming end of data."
|
|
518
|
+
)
|
|
519
|
+
break
|
|
520
|
+
|
|
521
|
+
result = all_highlights_data # This will be a list of Highlight models or dicts
|
|
412
522
|
else:
|
|
413
523
|
# Original behavior for other commands
|
|
414
524
|
logger.debug(
|
|
@@ -615,6 +725,23 @@ def create_click_command(
|
|
|
615
725
|
# For 'limit', required status and default remain as derived from its Optional[int] type hint
|
|
616
726
|
# current_click_required and current_default_value will be correctly False and None respectively.
|
|
617
727
|
|
|
728
|
+
# Special handling for 'get_all_highlights' command parameters
|
|
729
|
+
if api_method_name == "get_all_highlights":
|
|
730
|
+
if param.name == "cursor":
|
|
731
|
+
current_param_help = (
|
|
732
|
+
"[Ignored by CLI for get-all-highlights] " + param_help
|
|
733
|
+
)
|
|
734
|
+
current_click_required = (
|
|
735
|
+
False # Cursor is handled by CLI, not required from user
|
|
736
|
+
)
|
|
737
|
+
current_default_value = (
|
|
738
|
+
None # Explicitly set default to None for ignored param
|
|
739
|
+
)
|
|
740
|
+
elif param.name == "limit":
|
|
741
|
+
current_param_help = "Total maximum number of highlights to fetch across pages for get-all-highlights. If omitted, all are fetched."
|
|
742
|
+
# For 'limit', required status and default remain as derived from its Optional[int] type hint
|
|
743
|
+
# current_click_required and current_default_value will be correctly False and None respectively.
|
|
744
|
+
|
|
618
745
|
# Add the Click Option
|
|
619
746
|
click_params.append(
|
|
620
747
|
click.Option(
|
|
@@ -7,7 +7,7 @@ with open("README.md", "r") as readme:
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name="karakeep_python_api",
|
|
10
|
-
version="1.
|
|
10
|
+
version="1.4.0",
|
|
11
11
|
description="Community python client for the Karakeep API.", # Simplified description
|
|
12
12
|
long_description=long_description,
|
|
13
13
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api/openapi_reference.json
RENAMED
|
File without changes
|
{karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/requires.txt
RENAMED
|
File without changes
|
{karakeep_python_api-1.3.1 → karakeep_python_api-1.4.0}/karakeep_python_api.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|