Skip to content
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

PoC list books #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion kobo-annotations-exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ def main() -> None:
'-s',
type=check_date,
help="Export updated annotations since a given date (format: YYYY-MM-DD HH:MM:SS", )
parser.add_argument('--books',
'-b',
action='store_true',
help='List books')

args = parser.parse_args()

annotation_handler = AnnotationHandler(args.sqlite, args.format, args.directory, args.since)
annotation_handler = AnnotationHandler(args.sqlite, args.format, args.directory, args.since, args.books)
annotation_handler.handle()


Expand Down
18 changes: 14 additions & 4 deletions services/annotation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@ def __init__(self,
sqlite_file_name: str,
export_format: str,
export_directory: str,
export_since: datetime) -> None:
export_since: datetime,
books: str) -> None:
self.sqlite_file_name = sqlite_file_name
self.export_format = export_format
self.export_directory = export_directory
self.export_since = export_since
self.books = books

def handle(self) -> None:
exporter = instanciate_exporter(self.export_format)
retriever = AnnotationRetriever(self.sqlite_file_name)

annotations = retriever.retrieve(self.export_since)
exporter.export(annotations, self.export_directory)
if self.books:
for author in annotations:
print('---------')
print(author)
books = annotations[author]
for book in books:
print(book)
print('---------')
else:
exporter = instanciate_exporter(self.export_format)
exporter.export(annotations, self.export_directory)