X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yoweb-scrape;h=0ceeaa13c35226ee898c64011b9295845de2b520;hb=4d3174a853d79e278d81345057e7cc89dd152048;hp=720e886769131f60d64f854f9b26576a5d4ffe86;hpb=90592afd5da5f25e5a256f11186d851b4a149f47;p=ypp-sc-tools.db-live.git diff --git a/yoweb-scrape b/yoweb-scrape index 720e886..0ceeaa1 100755 --- a/yoweb-scrape +++ b/yoweb-scrape @@ -436,18 +436,17 @@ class ChatLogTracker: def force_redisplay(self): self._need_redisplay = True - def _onboard_event(self,timestamp,pirate,event): - try: pa = self._pl[pirate] - except KeyError: pa = None - if pa is not None and pa.v is self._v: + def _onboard_event(self,v,timestamp,pirate,event): + pa = self._pl.get(pirate, None) + if pa is not None and pa.v is v: pa.last_time = timestamp pa.last_event = event else: if pa is not None: del pa.v[pirate] - pa = PirateAboard(pirate, self._v, timestamp, event) + pa = PirateAboard(pirate, v, timestamp, event) self._pl[pirate] = pa - self._v[pirate] = pa - self._v['#lastinfo'] = timestamp + v[pirate] = pa + v['#lastinfo'] = timestamp self.force_redisplay() return pa @@ -518,15 +517,17 @@ class ChatLogTracker: l = l[l.find(' ')+1:] - def ob_x(who,event): - return self._onboard_event(timestamp, who, event) + def ob_x(pirate,event): + return self._onboard_event( + self._v, timestamp, pirate, event) def ob1(did): ob_x(m.group(1), did); return d(did) def oba(did): return ob1('%s %s' % (did, m.group(2))) - def disembark(who, how): - ob_x(who, 'leaving '+how) - del self._v[who] - del self._pl[who] + def disembark(v, timestamp, pirate, event): + self._onboard_event( + v, timestamp, pirate, 'leaving '+event) + del v[pirate] + del self._pl[pirate] m = rm('Going aboard the (\\S.*\\S)\\.\\.\\.$') if m: @@ -579,7 +580,8 @@ class ChatLogTracker: if cmdr == self._myself.name: how = 'manual: /%s' % cmd else: how = '/%s %s' % (cmd,cmdr) if cmd == 'a': each = ob_x - else: each = disembark + else: each = lambda who,how: disembark( + self._v, timestamp, who, how) if vn is not None: vn = vn.title() @@ -626,7 +628,8 @@ class ChatLogTracker: m = rm('(\\w+) has left the vessel\.') if m: - disembark(m.group(1), 'disembarked') + pirate = m.group(1) + disembark(self._v, timestamp, pirate, 'disembarked') return d('disembarked') return d('not matched')