Boss

Final Boss: Launch the Lantern Network

The boss
Boss Fight!
Every passing test breaks a shield.

This is it, apprentice. Every island has sent its repair list, and the Guild Council has gathered at the great lighthouse. The model, the storage and the command parser are ready (they're in your starter code). Now wire them into one app and light the whole network.

After this boss, one last lesson waits: a project you design yourself.

Assignment

Complete LanternNetwork. Its store is loaded from path in __init__.

  1. execute(line): parse the command, run it, and return a reply. Save the store after every change.
    • add: "added #1: Fix the bridge [Ember, p1]"
    • done: "lit #1: Fix the bridge"
    • list: self.list_tasks(island)
    • report: self.report()
  2. list_tasks(island=None): one line per task (only that island's tasks, if given), sorted by priority and then id: "#1 [ ] Fix the bridge (Ember, p1)". Use [x] for done tasks. Return "no tasks" if there are none.
  3. report(): lines joined with "\n":
    Lantern Network report
    Ember: 1/2 lit
    Frost: 0/1 lit
    Total: 1/3 lit (33%)
    Islands are sorted A to Z, and the percentage is round(100 * lit / total) (use 0% when there are no tasks). If there is at least one task and every task is done, add a last line: All lanterns lit! The network is online.
  4. run(lines): return the replies for every line. If a line raises ValueError or KeyError, its reply is "error: <message>" (use err.args[0]), and processing continues.