chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
but prettier like this
[ypp-sc-tools.main.git]
/
yoweb-scrape
diff --git
a/yoweb-scrape
b/yoweb-scrape
index e14719210d443c96e7b65ae8a93dc4e37924be36..a8a1a1169b0ee5f4ddb4b5548575d53b3c9ae348 100755
(executable)
--- a/
yoweb-scrape
+++ b/
yoweb-scrape
@@
-10,6
+10,7
@@
import urllib2
import errno
import sys
import re as regexp
import errno
import sys
import re as regexp
+import random
from optparse import OptionParser
from BeautifulSoup import BeautifulSoup
from optparse import OptionParser
from BeautifulSoup import BeautifulSoup
@@
-27,7
+28,7
@@
standingvals = ('Able/Distinguished/Respected/Master'+
pirate_ref_re = regexp.compile('^/yoweb/pirate\\.wm')
pirate_ref_re = regexp.compile('^/yoweb/pirate\\.wm')
-max_pirate_namelen =
20
+max_pirate_namelen =
12
def debug(m):
def debug(m):
@@
-44,6
+45,10
@@
class Fetcher:
if oe.errno != errno.EEXIST: raise
self._cache_scan(time.time())
if oe.errno != errno.EEXIST: raise
self._cache_scan(time.time())
+ def _default_ocean(self):
+ if self.ocean is None:
+ self.ocean = 'ice'
+
def _cache_scan(self, now):
# returns list of ages, unsorted
ages = []
def _cache_scan(self, now):
# returns list of ages, unsorted
ages = []
@@
-119,6
+124,7
@@
class Fetcher:
return data
def yoweb(self, kind, tail, max_age):
return data
def yoweb(self, kind, tail, max_age):
+ self._default_ocean()
url = 'http://%s.puzzlepirates.com/yoweb/%s%s' % (
self.ocean, kind, tail)
return self.fetch(url, max_age)
url = 'http://%s.puzzlepirates.com/yoweb/%s%s' % (
self.ocean, kind, tail)
return self.fetch(url, max_age)
@@
-312,7
+318,7
@@
class StandingsTable:
self._cw = col_width-1
def _pline(self, pirate, puzstrs):
self._cw = col_width-1
def _pline(self, pirate, puzstrs):
- self.s += ' %-*s' % (max
_pirate_namelen
, pirate)
+ self.s += ' %-*s' % (max
(max_pirate_namelen, 14)
, pirate)
for v in puzstrs:
self.s += ' %-*.*s' % (self._cw,self._cw, v)
self.s += '\n'
for v in puzstrs:
self.s += ' %-*.*s' % (self._cw,self._cw, v)
self.s += '\n'
@@
-376,7
+382,7
@@
def do_standings_crew_of(args, bu):
if not members: continue
tab.literalline('%s:' % rank)
for p in members:
if not members: continue
tab.literalline('%s:' % rank)
for p in members:
- pi = PirateInfo(p,
1800
)
+ pi = PirateInfo(p,
random.randint(900,1800)
)
tab.pirate(pi)
print tab.results()
tab.pirate(pi)
print tab.results()
@@
-389,10
+395,10
@@
actions:
yoweb-scrape [--ocean OCEAN ...] pirate PIRATE
yoweb-scrape [--ocean OCEAN ...] crew-of PIRATE
yoweb-scrape [--ocean OCEAN ...] standings-crew-of PIRATE
yoweb-scrape [--ocean OCEAN ...] pirate PIRATE
yoweb-scrape [--ocean OCEAN ...] crew-of PIRATE
yoweb-scrape [--ocean OCEAN ...] standings-crew-of PIRATE
+ yoweb-scrape [--ocean OCEAN ...] ship-aid CHAT-LOG
''')
ao = pa.add_option
''')
ao = pa.add_option
- ao('-O','--ocean',dest='ocean', metavar='OCEAN',
- default='ice',
+ ao('-O','--ocean',dest='ocean', metavar='OCEAN', default=None,
help='select ocean OCEAN')
ao('--cache-dir', dest='cache_dir', metavar='DIR',
default='~/.yoweb-scrape-cache',
help='select ocean OCEAN')
ao('--cache-dir', dest='cache_dir', metavar='DIR',
default='~/.yoweb-scrape-cache',
@@
-406,6
+412,7
@@
actions:
help='show ship duty station puzzles')
(opts,args) = pa.parse_args()
help='show ship duty station puzzles')
(opts,args) = pa.parse_args()
+ random.seed()
if len(args) < 1:
pa.error('need a mode argument')
if len(args) < 1:
pa.error('need a mode argument')