def manacost(self): syms = [] n = self.soup.find('div', id=get_card_prefix(self.soup)+"manaRow") if n is None: return [] for o in n.findAll('img'): sym = o['alt'].lower().strip() sym = symbols.translate(sym) syms.append(sym) return map(str, syms)
def manacost(self): syms = [] n = self.soup.find("div", id=self.PREFIX2 + "manaRow") if n is None: return [] for o in n.findAll("img"): sym = o["alt"].lower().strip() sym = symbols.translate(sym) syms.append(sym) return map(str, syms)
def render(self, fmt, idx): if (fmt == 'text'): lines = '-' * (abs(self.diff) - 1) return ('/' + lines if (self.direction == self.get_flipside()) else lines + '\\') relpos = self.get_relpos() pos = self.get_pos(idx) sym = self.get_symbol( '_'.join([ 'lane', 'split' if self.diff > 0 else 'join', self.sidename[self.side] ]), relpos, pos) width = abs(self.diff) xpos = relpos[0] + pos sym.scale(width, 1) if (width > 1): sym.translate(-xpos * (1 - 1 / width), 0) return sym
def gather_contents(soupnode): """ Gather contents from a BeautifulSoup node, stripping HTML, replacing symbols, etc. """ # replace images with text, e.g. {B}, {TAP}, etc. for n in soupnode.findAll('img'): symbol = n['alt'].lower().strip() our_symbol = symbols.translate(symbol) # may raise KeyError n.replaceWith("{" + our_symbol + "}") s = string.join([str(x) for x in soupnode.contents], "").strip() s = strip_html(s) return replace_chars(s)