From: Ian Jackson Date: Fri, 15 May 2009 18:24:38 +0000 (+0100) Subject: table output works X-Git-Tag: 1.0~70 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=commitdiff_plain;h=cbea021e8d7b7955cfe31ded5e832817c9c94edf table output works --- diff --git a/yoweb-scrape b/yoweb-scrape index 493ef53..2d08d26 100755 --- a/yoweb-scrape +++ b/yoweb-scrape @@ -292,31 +292,50 @@ class CrewInfo(SomethingSoupInfo): return `(self.crew, self.msgs)` class StandingsTable: - def __init__(self, use_puzzles=puzzles): + def __init__(self, use_puzzles=None, col_width=6): + if use_puzzles is None: + if opts.ship_duty: + use_puzzles=[ + 'Navigating','Battle Navigation', + 'Gunning', + ['Sailing','Rigging'], + 'Bilging', + 'Carpentry', + 'Treasure Haul' + ] + else: + use_puzzles=puzzles self._puzzles = use_puzzles self.s = '' + self._cw = col_width-1 def _pline(self, pirate, puzstrs): - self.s += '%-*s' % (max_pirate_namelen, pirate) + self.s += ' %-*s' % (max_pirate_namelen, pirate) for v in puzstrs: - self.s += ' %-*.*s' % (5,5, v) + self.s += ' %-*.*s' % (self._cw,self._cw, v) self.s += '\n' def _puzstr(self, pi, puzzle): if not isinstance(puzzle,list): puzzle = [puzzle] try: standing = max([pi.standings[p] for p in puzzle]) except KeyError: return '?' - c1 = standingvals[standing][0] - if standing < 3: c1 = c1.lower() # 3 = Master - hashes = '*' * (standing / 2) - equals = '+' * (standing % 2) - return c1 + hashes + equals + if not standing: return '' + s = '' + if self._cw > 4: + c1 = standingvals[standing][0] + if standing < 3: c1 = c1.lower() # 3 = Master + s += `standing` + if self._cw > 5: + s += ' ' + s += '*' * (standing / 2) + s += '+' * (standing % 2) + return s def headings(self): def puzn_redact(name): if isinstance(name,list): return '/'.join( - ["%.2s" % puzn_redact(n) + ["%.*s" % (self._cw/2, puzn_redact(n)) for n in name]) spc = name.find(' ') if spc < 0: return name @@ -380,6 +399,10 @@ actions: help='enable debugging output') ao('-q','--quiet', action='store_true', dest='quiet', help='suppress warning output') + + ao('--ship-duty', action='store_true', dest='ship_duty', + help='show ship duty station puzzles') + (opts,args) = pa.parse_args() if len(args) < 1: