Skip to content

Commit

Permalink
docs: Improve printouts for both Zotero and Readwise operations
Browse files Browse the repository at this point in the history
  • Loading branch information
e-alizadeh committed Jan 3, 2022
1 parent 6b79fc9 commit 5a22717
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 5 additions & 4 deletions zotero2readwise/readwise.py
Expand Up @@ -118,7 +118,7 @@ def post_zotero_annotations_to_readwise(
self, zotero_annotations: List[ZoteroItem]
) -> None:
print(
f"Start formatting {len(zotero_annotations)} annotations/notes...\n"
f"\nReadwise: Push {len(zotero_annotations)} Zotero annotations/notes to Readwise...\n"
f"It may take some time depending on the number of highlights...\n"
f"A complete message will show up once it's done!\n"
)
Expand All @@ -142,11 +142,12 @@ def post_zotero_annotations_to_readwise(
rw_highlights.append(rw_highlight.get_nonempty_params())
self.create_highlights(rw_highlights)

finished_msg = f"\n{len(rw_highlights)} highlights were successfully uploaded to Readwise.\n"
finished_msg = f"\n{len(rw_highlights)} highlights were successfully uploaded to Readwise.\n\n"
if self.failed_highlights:
finished_msg += (
f"NOTE: {len(self.failed_highlights)} highlights (out of {len(self.failed_highlights)}) failed.\n"
f"You can run `save_failed_items_to_json()` class method to save those items."
f"NOTE: {len(self.failed_highlights)} highlights (out of {len(self.failed_highlights)}) failed "
f"to upload to Readwise.\n"
f"You can run `save_failed_items_to_json()` class method to save those items.\n"
)
print(finished_msg)

Expand Down
11 changes: 4 additions & 7 deletions zotero2readwise/zotero.py
Expand Up @@ -195,7 +195,7 @@ def format_item(self, annot: Dict) -> ZoteroItem:
def format_items(self, annots: List[Dict]) -> List[ZoteroItem]:
formatted_annots = []
print(
f"Start formatting {len(annots)} annotations/notes...\n"
f"ZOTERO: Start formatting {len(annots)} annotations/notes...\n"
f"It may take some time depending on the number of annotations...\n"
f"A complete message will show up once it's done!\n"
)
Expand All @@ -206,10 +206,10 @@ def format_items(self, annots: List[Dict]) -> List[ZoteroItem]:
self.failed_items.append(annot)
continue

finished_msg = "\nFormatting job is done!!\n"
finished_msg = "\nZOTERO: Formatting Zotero Items is completed!!\n\n"
if self.failed_items:
finished_msg += (
f"NOTE: {len(self.failed_items)} annotations/notes (out of {len(annots)}) failed to format.\n"
f"\nNOTE: {len(self.failed_items)} Zotero annotations/notes (out of {len(annots)}) failed to format.\n"
f"You can run `save_failed_items_to_json()` class method to save those items."
)
print(finished_msg)
Expand All @@ -223,10 +223,7 @@ def save_failed_items_to_json(self, json_filepath_failed_items: str = None):
out_filepath = FAILED_ITEMS_DIR.joinpath("failed_zotero_items.json")
with open(out_filepath, "w") as f:
dump(self.failed_items, f)
print(
f"{len(self.failed_items)} annotations/notes failed to format.\n"
f"Detail of failed items are saved into {out_filepath}"
)
print(f"\nZOTERO: Detail of failed items are saved into {out_filepath}\n")


def retrieve_all_annotations(zotero_client: Zotero) -> List[Dict]:
Expand Down

0 comments on commit 5a22717

Please sign in to comment.