From 5fe0bb0d7edc684b7a37b919b5d7ff44f72e45b8 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Fri, 8 Jan 2010 19:02:18 -0700 Subject: [PATCH] fix .mtg set regex --- plugins/mtg.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/mtg.py b/plugins/mtg.py index 61bd9c2..e3054f3 100644 --- a/plugins/mtg.py +++ b/plugins/mtg.py @@ -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)