commit bb10c391cc250213189c5a8e11da6578b29f4aa3
parent 4f4cb6699ad8eecca6d7c1fb465c88d9e37b0783
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Sat, 15 Dec 2012 19:16:01 +0100
+scripts
Diffstat:
prefix.pl | | | 24 | ++++++++++++++++++++++++ |
wellformed.py | | | 58 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/prefix.pl b/prefix.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+my $prefix;
+my $skip;
+
+while (<>) {
+ if (/^([^ a-z(][^a-z(]*)(( \(|:).*)$/) {
+ $prefix = $1;
+ if ($2 =~ / \((.*)/) {
+ print "<$prefix> /me $1\n";
+ }
+ $skip = 1;
+ }
+ $prefix = "" if /^$/;
+ if (!$skip) {
+ if ($prefix) {
+ print "<$prefix>$_";
+ } else {
+ print "<MASTER> $_" if (!/^$/);
+ }
+ } else {
+ $skip = 0;
+ }
+}
diff --git a/wellformed.py b/wellformed.py
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+
+import sys
+
+status = {}
+no = 0
+onstage = 0
+maxonstage = 0
+reached = 0
+
+while True:
+ l = sys.stdin.readline()
+ no += 1
+ if not l:
+ break
+ f = l.strip().split(' ')
+ if len(f) < 2:
+ continue
+ p = f[0]
+ fw = f[1]
+ if p not in status.keys():
+ status[p] = "out"
+ if fw == "/join":
+ if status[p] != "out":
+ print("line %d: %s joins but is already on stage" % (no, p))
+ status[p] = "in"
+ onstage += 1
+ if onstage > maxonstage:
+ maxonstage = onstage
+ reached = no
+ elif fw == "/part":
+ if status[p] != "in":
+ print("line %d: %s leaves but is already out of stage" % (no, p))
+ status[p] = "out"
+ onstage -= 1
+ elif fw == "/nick":
+ fw2 = "<" + f[2] + ">"
+ if fw2 not in status.keys():
+ status[fw2] = "out"
+ if status[fw2] != "out":
+ print("line %d: %s name clash" % (no, fw2))
+ if status[p] != "in":
+ print("line %d: %s leaves but is already out of stage" % (no, p))
+ status[p] = "out"
+ status[fw2] = "in"
+ elif fw.startswith("Rideau") and p == "<MASTER>":
+ for x in status.keys():
+ if x == "<MASTER>":
+ continue
+ if status[x] != "out":
+ print("line %d: %s still on stage at act end" % (no, x))
+ elif p != "<MASTER>":
+ if status[p] != "in":
+ print("line %d: %s speaks but is out of stage" % (no, p))
+ status[p] = "in"
+
+
+print("Max on stage: %d at line %d" % (maxonstage, reached))