From e9615860253eb8bfdb50d80fbea58002bc350c5b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 17 May 2009 13:56:49 +0100 Subject: [PATCH] show last vessel if we aren't on a vessel --- TODO | 1 - yoweb-scrape | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index ffe6b98..c4afe73 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,2 @@ yoweb-scrape improve the docs - ship-aid should show last vessel if we're not on a vessel 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() -- 2.30.2