Просмотр исходного кода

Change datatype for scratchings to set

Foppe Hemminga 6 лет назад
Родитель
Сommit
58ecd8d3c9
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      _bs.py

+ 6 - 6
_bs.py

@@ -169,15 +169,15 @@ def process_scratchings(this_data, this_venue):
     header = this_scr.select('h3', text=re.compile('Scratchings'))[0]
     div = header.findNext('table')
 
-    scratchings = []
+    scratchings = set()
     early_scratchings = scrape_scratchings(div, this_venue)
+    scratchings.update(early_scratchings)
     header = this_scr.select('h3', text=re.compile('Late Scratchings'))[0]
     div = header.findNext('table')
     late_scratchings = scrape_scratchings(div, this_venue)
-    scratchings = early_scratchings + late_scratchings
-    # Make sure the scratchings list contains distinct entries
-    scratchings = list(set(scratchings))
-    # assert len(scratchings) == int(scratchings_count), 'len(scratchings) {} == scratchings_count {}'.format(
-    #     len(scratchings), scratchings_count)
+    scratchings.update(late_scratchings)
+
+    assert len(scratchings) == int(scratchings_count), 'len(scratchings) {} == scratchings_count {}'.format(
+         len(scratchings), scratchings_count)
     # pprint(scratchings)
     return scratchings