-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.') |