From e4a5b51307973cd024aecb7c94670501f0c9e9b5 Mon Sep 17 00:00:00 2001 From: Lee Matos Date: Fri, 14 Jul 2017 23:32:53 -0400 Subject: [PATCH] refactor no cards found exit case to be more pythonic (#123) replace counting loop with len() --- mtgs_scraper.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mtgs_scraper.py b/mtgs_scraper.py index 2a6481c2..278bac6f 100644 --- a/mtgs_scraper.py +++ b/mtgs_scraper.py @@ -42,10 +42,7 @@ def parse_mtgs(mtgs, manual_cards=[], card_corrections=[], delete_cards=[], rela cards.remove(card) # if we didn't find any cards, let's bail out to prevent overwriting good data - count = 0 - for card in cards: - count = count + 1 - if count < 1: + if len(cards) < 1: sys.exit("No cards found, exiting to prevent file overwrite") cards2 = [] @@ -270,4 +267,4 @@ def list_mtgs_gallery(url=''): cardstree = tree.xpath('//*[contains(@class, "log-card")]') for child in cardstree: cards.append(child.text) - return cards \ No newline at end of file + return cards