4 signal.signal(signal.SIGINT, signal.SIG_DFL)
10 #from optparse import OptionParser
12 from BeautifulSoup import BeautifulSoup
22 url = ('http://yppedia.puzzlepirates.com/%s_Ocean' %
23 urllib.quote(ocean,''))
24 dataf = urllib2.urlopen(url)
25 soup = BeautifulSoup(dataf)
28 def title_arch_arch(t):
30 if t is None: return None
31 m = title_arch_re.match(t)
36 a = title_arch_arch(t)
37 if a is None: return False
40 title_arch_re = regexp.compile('\\S+ Archipelago \\((\\S+)\\)$')
41 title_any_re = regexp.compile('(\\S.*\\S) \((\\S+)\\)$')
42 href_img_re = regexp.compile('\\.png$')
45 firstarch = soup.find('a', attrs = {'title': title_arch_ok})
48 def findall_title_arch_ok(t):
49 return t.findAll('a', attrs = {'title': title_arch_ok})
51 def is_archestable(u):
52 if u.name != 'table': return False
53 return len(findall_title_arch_ok(u)) > 1
55 archestable = firstarch.findParent(is_archestable)
56 debug('at',archestable)
58 arches = findall_title_arch_ok(archestable)
62 return len(v.findAll(text = regexp.compile('.*Large'))) > 0
64 return u.findParent(is_island)
65 arches = map(arch_up_map, arches)
69 links = arch.findAll('a', href=True)
71 a = title_arch_arch(links[0]['title'])
74 for link in links[1:]:
76 if href_img_re.search(link['href']): continue
77 m = title_any_re.match(link['title'])
78 assert(m.group(2) == ocean)
79 print 'island', m.group(1)