fix .mtg set regex

This commit is contained in:
Ryan Hitchman 2010-01-08 19:02:18 -07:00
parent bde89835fc
commit 5fe0bb0d7e
1 changed files with 2 additions and 4 deletions

View File

@ -18,15 +18,13 @@ def mtg(inp):
text = card.find('p')
type = text.text
global t
t=text.find('b')
text = text.find('b').text_content()
text = re.sub(r'\(.*?\)', '', text) # strip parenthetical explanations
text = re.sub(r'\.(\S)', r'. \1', text) # fix spacing
global printing
printings = card.find('table/tr/td/img').getparent().text_content()
printings = re.findall(r'\s*(.*?) \((.*?)\)', ' '.join(printings.split()))
printings = re.findall(r'\s*(.+?(?: \([^)]+\))*) \((.*?)\)',
' '.join(printings.split()))
printing_out = ', '.join('%s (%s)' % (set_abbrevs.get(x[0], x[0]),
rarity_abbrevs.get(x[1], x[1]))
for x in printings)