import sys if not 'anki' in sys.modules: from anknotes import detect_see_also_changes detect_see_also_changes.main()
def see_also(steps=None, showAlerts=None, validationComplete=False, controller=None, upload=True): all_args = locals() show_tooltip_enabled = False if controller is None: check = reload_collection() if check: log("See Also --> 2. Loading Controller", 'automation') callback_args = dict(all_args) del callback_args['controller'] load_controller(lambda x, *xa, **xkw: see_also(controller=x, **callback_args)) else: log("See Also --> 1. Loading Collection", 'automation') reload_collection(lambda *xa, **xkw: see_also(**all_args)) return False if not steps: steps = range(1, 10) if isinstance(steps, int): steps = [steps] if not upload: if 3 in steps: steps.remove(3) if 7 in steps: steps.remove(7) steps = list(steps) log("See Also --> 3. Proceeding: " + ', '.join(map(str, steps)), 'automation') multipleSteps = (len(steps) > 1) if showAlerts is None: showAlerts = not multipleSteps if multipleSteps: show_tooltip_enabled = show_tooltip.enabled if hasattr(show_tooltip, 'enabled') else None show_tooltip.enabled = False remaining_steps = steps if 1 in steps: # Should be unnecessary once See Also algorithms are finalized log(" > See Also: Step 1: Process Un Added See Also Notes", crosspost='automation') controller.process_unadded_see_also_notes() if 2 in steps: log(" > See Also: Step 2: Create Auto TOC Evernote Notes", crosspost='automation') controller.create_toc_auto() if 3 in steps: if validationComplete: log(" > See Also: Step 3B: Validate and Upload Auto TOC Notes: Upload Validated Notes", crosspost='automation') upload_validated_notes(multipleSteps) validationComplete = False else: steps = [-3] if 4 in steps: log(" > See Also: Step 4: Extract Links from TOC", crosspost='automation') controller.anki.extract_links_from_toc() if 5 in steps: log(" > See Also: Step 5: Insert TOC/Outline Links Into Anki Notes' See Also Field", crosspost='automation') controller.anki.insert_toc_into_see_also() if 6 in steps: log(" > See Also: Step 6: Update See Also Footer In Evernote Notes", crosspost='automation') from anknotes import detect_see_also_changes detect_see_also_changes.main() if 7 in steps: if validationComplete: log(" > See Also: Step 7B: Validate and Upload Modified Evernote Notes: Upload Validated Notes", crosspost='automation') upload_validated_notes(multipleSteps) else: steps = [-7] if 8 in steps: log(" > See Also: Step 8: Insert TOC/Outline Contents Into Anki Notes", crosspost='automation') controller.anki.insert_toc_and_outline_contents_into_notes() do_validation = steps[0] * -1 if do_validation > 0: log(" > See Also: Step %dA: Validate and Upload %s Notes: Validate Notes" % ( do_validation, {3: 'Auto TOC', 7: 'Modified Evernote'}[do_validation]), crosspost='automation') remaining_steps = remaining_steps[remaining_steps.index(do_validation):] callback_args = all_args callback_args.update(dict(steps=remaining_steps, showAlerts=False, validationComplete=True)) validate_pending_notes(showAlerts, callback=lambda *xargs, **xkwargs: see_also(**callback_args)) if multipleSteps: show_tooltip.enabled = show_tooltip_enabled