From 7ccf4d0dc7da358231f3a7b10bfef63645a27ec5 Mon Sep 17 00:00:00 2001 From: Bram Vandenbussche Date: Sun, 31 Jul 2022 14:47:51 +0200 Subject: [PATCH 1/4] Allow ExportingReader classes to skip the Text Input dialogue --- action.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/action.py b/action.py index 05e0cd2..a878404 100644 --- a/action.py +++ b/action.py @@ -822,7 +822,14 @@ def import_annotations(self, reader_app): if reader_app_class.SUPPORTS_FILE_CHOOSER: raw_data = ImportAnnotationsFileDialog(self, reader_app_class).text() else: - raw_data = ImportAnnotationsTextDialog(self, reader_app, reader_app_class).text() + try: + if reader_app_class.REQUIRES_TEST_INPUT == True: + raw_data = ImportAnnotationsTextDialog(self, reader_app, reader_app_class).text() + else: + raw_data = "-" + except AttributeError: + raw_data = ImportAnnotationsTextDialog(self, reader_app, reader_app_class).text() + if(raw_data): # Instantiate reader_app_class rac = reader_app_class(self) From 8b304868ae9f6615c177c7b086adf3ddbd427cd8 Mon Sep 17 00:00:00 2001 From: Bram Vandenbussche Date: Sun, 31 Jul 2022 15:31:40 +0200 Subject: [PATCH 2/4] If selected ExportingReader doesn't need a book selected, don't stop it --- action.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/action.py b/action.py index a878404..7c8391f 100644 --- a/action.py +++ b/action.py @@ -803,14 +803,22 @@ def import_annotations(self, reader_app): supported_reader_apps = ReaderApp.get_reader_app_classes() reader_app_class = supported_reader_apps[reader_app] + try: + requires_book_selected = reader_app_class.REQUIRES_BOOK_SELECTED + except AttributeError: + requires_book_selected = True + # Save a reference for merge_annotations self.reader_app_class = reader_app_class - self.selected_mi = get_selected_book_mi(self.get_options(), - msg=self.SELECT_DESTINATION_MSG, - det_msg=self.SELECT_DESTINATION_DET_MSG) - if not self.selected_mi: - return + if requires_book_selected: + self.selected_mi = get_selected_book_mi(self.get_options(), + msg=self.SELECT_DESTINATION_MSG, + det_msg=self.SELECT_DESTINATION_DET_MSG) + if not self.selected_mi: + return + else: + self.selected_mi = None ra_confidence = reader_app_class.import_fingerprint From 16ec0a9bbd8d1b8b47ab10d15e599c843b80c249 Mon Sep 17 00:00:00 2001 From: Bram Vandenbussche Date: Sun, 31 Jul 2022 22:07:10 +0200 Subject: [PATCH 3/4] Improve documentation of SampleExportingApp --- readers/SampleExportingApp.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/readers/SampleExportingApp.py b/readers/SampleExportingApp.py index 1beca4b..28afd9e 100755 --- a/readers/SampleExportingApp.py +++ b/readers/SampleExportingApp.py @@ -86,6 +86,16 @@ class SampleExportingApp(ExportingReader): # Change this to True when developing a new class from this template SUPPORTS_EXPORTING = True + # If this is set to true, a text dialog will be shown prior to calling parse_exported_highlights + # and the contents of the dialog will be passed in via the raw parameter + # If set to false, no dialog will be displayed and parse_exported_highlights will be called with raw == "-" + REQUIRES_TEST_INPUT = True + + # If this is set to true, it means the class needs the user to select a book prior to invoking this action. + # If a book isn't selected, the user will receive a warning and nothing will happen + # If this is set to false, the user can call the class with 0 or more books selected, it's up to you to handle all scenarios + REQUIRES_BOOK_SELECTED = False + # Change this to True to use a file chooser instead of text input box for import SUPPORTS_FILE_CHOOSER = False import_file_name_filter = "All files (*)" From aada154c7310a65131194045e3eb1db959027a1f Mon Sep 17 00:00:00 2001 From: Bram Vandenbussche Date: Sun, 31 Jul 2022 22:15:25 +0200 Subject: [PATCH 4/4] Provide sensible default value --- readers/SampleExportingApp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readers/SampleExportingApp.py b/readers/SampleExportingApp.py index 28afd9e..cd6bedf 100755 --- a/readers/SampleExportingApp.py +++ b/readers/SampleExportingApp.py @@ -94,7 +94,7 @@ class SampleExportingApp(ExportingReader): # If this is set to true, it means the class needs the user to select a book prior to invoking this action. # If a book isn't selected, the user will receive a warning and nothing will happen # If this is set to false, the user can call the class with 0 or more books selected, it's up to you to handle all scenarios - REQUIRES_BOOK_SELECTED = False + REQUIRES_BOOK_SELECTED = True # Change this to True to use a file chooser instead of text input box for import SUPPORTS_FILE_CHOOSER = False