X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=yoweb-scrape;h=ed9533ef51c513b4628673712880bc9a0b0b1e3c;hp=b12b5032fcb9eb7c09cfdfa867dbd34f57eb8e65;hb=e9615860253eb8bfdb50d80fbea58002bc350c5b;hpb=df5a08b4a0046990ff235a9fdc17262ac071deaa diff --git a/yoweb-scrape b/yoweb-scrape index b12b503..ed9533e 100755 --- a/yoweb-scrape +++ b/yoweb-scrape @@ -438,6 +438,7 @@ class ChatLogTracker: self._progress = [0, os.fstat(self._f.fileno()).st_size] self._disembark_myself() self._need_redisplay = False + self._lastvessel = None def _disembark_myself(self): self._v = None @@ -620,7 +621,7 @@ class ChatLogTracker: pn = self._myself.name vn = m.group(1) v = self._vessel_lookup(vn, timestamp, dm, create=True) - self._vessel = vn + self._lastvessel = self._vessel = vn self._v = v ob_x(pn, 'we boarded') self.expire_garbage(timestamp) @@ -807,14 +808,22 @@ class ChatLogTracker: def myname(self): # returns our pirate name return self._myself.name - def vessel(self): - # returns the vessel we're aboard or None + def vesselname(self): + # returns the vessel name we're aboard or None return self._vessel - def aboard(self): - # returns a list of PirateAboard sorted by name - if self._v is None: return [] - return [ self._v[pn] - for pn in sorted(self._v.keys()) + def lastvesselname(self): + # returns the last vessel name we were aboard or None + return self._lastvessel + def aboard(self, vesselname=True): + # returns a list of PirateAboard the vessel + # sorted by pirate name + # you can pass this None and you'll get [] + # or True for the current vessel (which is the default) + if vesselname is True: v = self._v + else: v = self._vl.get(vesselname.title()) + if v is None: return [] + return [ v[pn] + for pn in sorted(v.keys()) if not pn.startswith('#') ] #---------- implementations of actual operation modes ---------- @@ -980,9 +989,18 @@ def do_ship_aid(args, bu): s = "%s" % track.myname() - vn = track.vessel() - if vn is None: s += " not on a vessel" - else: s += " on board the %s" % vn + vn = track.vesselname() + if vn is not None: + s += " on board the %s" % vn + + if vn is None: + vn = track.lastvesselname() + if vn is not None: + s += " ashore from the %s" % vn + + if vn is None: + s += " not on a vessel" + s += " at %s\n" % time.strftime("%Y-%m-%d %H:%M:%S") tbl = StandingsTable()