2016-12-16 00:29:59 -06:00
|
|
|
"""Outputters take scraped objects and save them to a certain format."""
|
|
|
|
|
2016-11-27 01:52:45 -06:00
|
|
|
from . import json, pickle
|
2016-11-26 23:09:12 -06:00
|
|
|
|
2016-12-16 00:29:59 -06:00
|
|
|
OUTPUTTERS = [json, pickle]
|
2016-11-26 23:09:12 -06:00
|
|
|
|
2016-12-16 00:29:59 -06:00
|
|
|
def get_outputter(name):
|
|
|
|
"""Get the outputter with the specified name."""
|
|
|
|
for outputter in OUTPUTTERS:
|
2016-11-26 23:09:12 -06:00
|
|
|
if outputter.__name__.endswith(".{}".format(name)):
|
|
|
|
return outputter
|
|
|
|
|
|
|
|
raise Exception("Unknown outputter: {}".format(name))
|