User:Kevin Reid/Task list updater.e

From Rosetta Code

This script updates the classified task lists I maintain (such as User:Kevin Reid/E tasks) by moving completed tasks to the completed list and adding new tasks. It takes a language name (with underscores) as a parameter, and outputs the updated source of the task page on stdout.

<lang e>#!/usr/bin/env rune pragma.syntax("0.9") pragma.enable("accumulator")

def [lang] := interp.getArgs()

def unimpURL := <http>[`//rosettacode.org/wiki/Reports:Tasks_not_implemented_in_$lang`] def catURL := <http>[`//rosettacode.org/mw/index.php?title=User:Kevin_Reid/${lang}_tasks&action=raw`]

def unimpText := unimpURL.getText() def catText := catURL.getText()

  1. kludgy...

def unimps := accum [].asSet() for rx`.*?

  • <a href=".*?" title=".*?">(@title.*?)</a>
  • .*` in unimpText.split("id=\"Not_Considered\"")[0].split("\n") { _.with(title) } def catOut := stdout var toAdd := unimps.sort() var completed := [].asSet() var inCompleted := false var inClassifySection := false for line in catText.split("\n") { switch (line) { match rx`\* \[\[(@title.*?)\]\](@note.*)` { toAdd without= title if (!unimps.contains(title) && note.startOf("improve") == -1 && note.startOf("omit") == -1) { # now implemented, so don't print completed with= line } else { if (inClassifySection && toAdd.size().aboveZero()) { var add := toAdd.getElements()[0] if (add < title) { catOut.println(`* $add`) toAdd without= add } } if (inCompleted && completed.size().aboveZero()) { var add := completed.getElements()[0] if (add < line) { catOut.println(line) completed without= add } } catOut.println(line) } } match rx`\s*\s*` { inCompleted := true completed sort= () catOut.println(line) } match rx`\s*\s*` { inCompleted := false for line in completed.sort() { catOut.println(line) } completed := [].asSet() catOut.println(line) } match rx`` { inClassifySection := true catOut.println(line) } match rx`` { inClassifySection := false for title in toAdd.sort() { catOut.println(`* $title`) } catOut.println(line) } match _ { catOut.println(line) } } }</lang>