Skip to content

Commit

Permalink
Merge UTM/UTSG docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kashav committed May 16, 2016
1 parent fa4dfcb commit e5834bd
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions uoftscrapers/scrapers/dates/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
from ..utils import Scraper
from .utsg import UTSGDates
from .utm import UTMDates

from collections import OrderedDict


class Dates:

@staticmethod
def scrape(location='.'):
def scrape(location='.', year=None):
Scraper.logger.info('Dates initialized.')
UTSGDates.scrape(location)

docs = OrderedDict()

for campus in UTSGDates, UTMDates:
dates = campus.scrape(location, year=year, save=False)

if dates is None:
continue

for date, doc in dates.items():
if date not in docs:
docs[date] = OrderedDict([
('date', date),
('events', [])
])
docs[date]['events'].extend(doc['events'])

for date, doc in docs.items():
Scraper.save_json(doc, location, date)

Scraper.logger.info('Dates completed.')

0 comments on commit e5834bd

Please sign in to comment.