chiark / gitweb /
track-chat-log shows something if you're not on a vessel to start with.
[ypp-sc-tools.db-test.git] / yoweb-scrape
index 1eeb8a36e0dace67cd9bfb08d3e110a627c691ae..c99b2b0c684362f3db3b4507823bba7af6bb2ce9 100755 (executable)
@@ -433,7 +433,7 @@ class ChatLogTracker:
                self._lbuf = ''
                self._progress = [0, os.fstat(self._f.fileno()).st_size]
 
-       def _refresh(self):
+       def force_redisplay(self):
                self._need_redisplay = True
 
        def _onboard_event(self,timestamp,pirate,event):
@@ -448,14 +448,14 @@ class ChatLogTracker:
                        self._pl[pirate] = pa
                        self._v[pirate] = pa
                self._v['#lastaboard'] = timestamp
-               self._refresh()
+               self.force_redisplay()
                return pa
 
        def _trash_vessel(self, v):
                for pn in v:
                        if pn.startswith('#'): continue
                        del self._pl[pn]
-               self._refresh()
+               self.force_redisplay()
 
        def expire_garbage(self, timestamp):
                for (vn,v) in list(self._vl.iteritems()):
@@ -546,7 +546,7 @@ class ChatLogTracker:
                        if pa.v is self._v:
                                pa.last_chat_time = timestamp
                                pa.last_chat_chan = what
-                               self._refresh()
+                               self.force_redisplay()
                                return d(what+' chat')
 
                m = rm('(\\w+) (?:issued an order|ordered everyone) "')
@@ -649,6 +649,7 @@ class ChatLogTracker:
                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())
                         if not pn.startswith('#') ]
@@ -706,9 +707,9 @@ def prep_chat_log(args, bu,
                max_myself_age=3600):
        if len(args) != 1: bu('this action takes only chat log filename')
        logfn = args[0]
-       logfn_re = '(?:.*/)?([A-Z][a-z]+)_([a-z]+)_chat-log-\\w+$'
+       logfn_re = '(?:.*/)?([A-Z][a-z]+)_([a-z]+)_'
        match = regexp.match(logfn_re, logfn)
-       if not match: bu('chat log filename is not in default format')
+       if not match: bu('chat log filename is not in expected format')
        (pirate, ocean) = match.groups()
        fetcher.default_ocean(ocean)
        
@@ -720,6 +721,8 @@ def prep_chat_log(args, bu,
        track.catchup(progress)
        opts.debug += 1
 
+       track.force_redisplay()
+
        return (myself, track)
 
 def do_track_chat_log(args, bu):
@@ -815,11 +818,9 @@ 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 at %s\n" % (
-                               vn, time.strftime("%Y-%m-%d %H:%M:%S"))
+               if vn is None: s += " not on a vessel?!"
+               else: s += " on board the %s" % vn
+               s += " at %s\n" % time.strftime("%Y-%m-%d %H:%M:%S")
 
                tbl = StandingsTable()
                tbl.headings()