chiark / gitweb /
Show sort order in display
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 27 May 2009 23:12:38 +0000 (00:12 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Wed, 27 May 2009 23:12:38 +0000 (00:12 +0100)
yoweb-scrape

index ca704f7..4369cab 100755 (executable)
@@ -389,7 +389,7 @@ class StandingsTable:
                s += '+' * (standing % 2)
                return s
 
-       def headings(self, lhs=''):
+       def headings(self, lhs='', rhs=None):
                def puzn_redact(name):
                        if isinstance(name,list):
                                return '/'.join(
@@ -399,7 +399,7 @@ class StandingsTable:
                        if spc < 0: return name
                        return name[0:min(4,spc)] + name[spc+1:]
                self._linecount = -2
-               self._pline(lhs, map(puzn_redact, self._puzzles), None)
+               self._pline(lhs, map(puzn_redact, self._puzzles), rhs)
                self._linecount = 0
        def literalline(self, line):
                self.s += line + '\n'
@@ -1034,6 +1034,7 @@ class KeyBasedSorter:
 
 class NameSorter(KeyBasedSorter):
        def compar_key(self, pi): return pi.name
+       def desc(self): return 'name'
 
 class SkillSorter(NameSorter):
        def __init__(self, relevant):
@@ -1043,7 +1044,10 @@ class SkillSorter(NameSorter):
                        if isinstance(p,basestring): self._avoid.add(p)
                        else: self._avoid |= set(p)
                self._avoid -= self._want
+               self._desc = '%s' % relevant
        
+       def desc(self): return self._desc
+
        def compar_key(self, pi):
                best_want = max([
                        pi.standings.get(puz,-1)
@@ -1092,7 +1096,8 @@ def ship_aid_core(myself, track, displayer, kreader):
                sort.lsort_pa(aboard)
 
                tbl = StandingsTable()
-               tbl.headings(' %d aboard' % len(aboard))
+               tbl.headings(' %d aboard' % len(aboard),
+                               '  sorted by '+sort.desc())
 
                for pa in aboard:
                        pi = pa.pirate_info()