- if match is None: continue
- standing = match.group(1)
- skills[duty] = standing
-
-# print `duty`, `standing`
-# if standing not in standings: continue
-# for i in range(0, len(standings)):
-# print `duty`, `standing`, i
-# if standing == standings[i]:
-# print `skills[duty]`
-# skills[duty].append(i)
-
-# self.skills = { }
-# for skill in duties:
-
- self.skills = skills
+ if match is None:
+ skl.soupm(key, ('duty "%s" unparseable'+
+ ' standing "%s"') % (duty, valstr))
+ continue
+ standing = match.group(match.lastindex)
+ standings[duty].append(standing)
+
+ self.standings = { }
+
+ for duty in duties:
+ sl = standings[duty]
+ if len(sl) > 1:
+ skl.msg('duty "%s" multiple standings %s' %
+ (duty, `sl`))
+ continue
+ if not len(sl):
+ skl.msg('duty "%s" no standing found' % duty)
+ continue
+ standing = sl[0]
+ for i in range(0, len(standingvals)-1):
+ if standing == standingvals[i]:
+ self.standings[duty] = i
+ if not duty in self.standings:
+ skl.msg('duty "%s" unknown standing "%s"' %
+ (duty, standing))
+
+ all_standings_ok = True
+ for duty in duties:
+ if not duty in self.standings:
+ self.needs_msgs(skl)
+
+ def _find_crewflag(self, cf, yoweb_re):
+ things = self.soup.findAll('a', href=regexp.compile(yoweb_re))
+ if len(things) != 1:
+ self.msg('zero or several %s id references found' % cf)
+ return None
+ thing = things[0]
+ id_re = '\\b%sid\\=(\\w+)$' % cf
+ id_haystack = thing['href']
+ match = regexp.compile(id_re).search(id_haystack)
+ if match is None:
+ self.soupm(thing, ('incomprehensible %s id ref'+
+ ' (%s in %s)') % (cf, id_re, id_haystack))
+ return None
+ name = ''.join(thing.findAll(text=True))
+ return (match.group(1), name)
+
+ def __init__(self, pirate):
+ SoupLog.__init__(self)
+
+ html = fetcher.yoweb('pirate.wm?target=', pirate)
+ self.soup = BeautifulSoup(html,
+ convertEntities=BeautifulSoup.HTML_ENTITIES
+ )
+
+ self._find_standings()
+
+ self.crew = self._find_crewflag('crew',
+ '^/yoweb/crew/info\\.wm')
+ self.flag = self._find_crewflag('flag',
+ '^/yoweb/flag/info\\.wm')
+