Add dict type to notes

This commit is contained in:
Marty Oehme 2023-02-22 12:02:00 +01:00
parent 721e308207
commit b6a28d8e6a
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -6,7 +6,7 @@
# annotations as 'csv' format and then point the script to the # annotations as 'csv' format and then point the script to the
# resulting file. # resulting file.
import sys import sys
from typing import List from typing import Dict, List
import papis.api import papis.api
import papis.commands.list import papis.commands.list
import papis.database import papis.database
@ -24,7 +24,7 @@ def main(fpath, db):
write_to_files(notes) write_to_files(notes)
def get_all_annotations(db, csv): def get_all_annotations(db, csv) -> Dict:
notes = {} notes = {}
note_file = "" note_file = ""
for row in csv: for row in csv:
@ -54,6 +54,17 @@ def get_all_annotations(db, csv):
return notes return notes
def get_documents(db, author, title) -> List:
return db.query(f"author:({author}) title:({title})")
def get_notefile(document) -> str | None:
note_file = papis.commands.list.run(notes=True, documents=document)
if not note_file:
return
return str(note_file[0])
# TODO Implement manual note creation # TODO Implement manual note creation
def manual_papis_entry(): def manual_papis_entry():
if input(f"Create note file now? [y/N] ") == "y": if input(f"Create note file now? [y/N] ") == "y":
@ -68,17 +79,6 @@ def manual_papis_entry():
return return
def get_documents(db, author, title) -> List:
return db.query(f"author:({author}) title:({title})")
def get_notefile(document) -> str | None:
note_file = papis.commands.list.run(notes=True, documents=document)
if not note_file:
return
return str(note_file[0])
# TODO implement custom formatting (akin to pubs-extract) # TODO implement custom formatting (akin to pubs-extract)
def format_entry(row) -> str: def format_entry(row) -> str:
text = f"> {row['HighlightText']}" text = f"> {row['HighlightText']}"
@ -104,7 +104,7 @@ def is_same_book(title):
return False return False
def write_to_files(notes): def write_to_files(notes: Dict):
# write to notes # write to notes
for f, entries in notes.items(): for f, entries in notes.items():
if f: if f: