<s> """<STR_LIT>""" <EOL> import flask <EOL> import lxml . html <EOL> from . utils import select , snake_case <EOL> from . views import FeaturedFeedTriggerView <EOL> app = flask . Flask ( __name__ ) <EOL> app . config . from_pyfile ( '<STR_LIT>' , silent = True ) <EOL> @ app . errorhandler ( <NUM_LIT> ) <EOL> def unauthorized ( e ) : <EOL> """<STR_LIT>""" <EOL> error = { '<STR_LIT:message>' : '<STR_LIT>' } <EOL> return flask . jsonify ( errors = [ error ] ) , <NUM_LIT> <EOL> @ app . after_request <EOL> def force_content_type ( response ) : <EOL> """<STR_LIT>""" <EOL> response . headers [ '<STR_LIT:Content-Type>' ] = '<STR_LIT>' <EOL> return response <EOL> @ app . before_request <EOL> def validate_channel_key ( ) : <EOL> """<STR_LIT>""" <EOL> channel_key = flask . request . headers . get ( '<STR_LIT>' ) <EOL> if not app . debug and channel_key != app . config . get ( '<STR_LIT>' ) : <EOL> flask . abort ( <NUM_LIT> ) <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:POST>' ] ) <EOL> def test_setup ( ) : <EOL> """<STR_LIT>""" <EOL> return flask . jsonify ( data = { '<STR_LIT>' : { } } ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def status ( ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' <EOL> class PictureOfTheDay ( FeaturedFeedTriggerView ) : <EOL> """<STR_LIT>""" <EOL> feed = '<STR_LIT>' <EOL> wiki = '<STR_LIT>' <EOL> def parse_entry ( self , entry ) : <EOL> """<STR_LIT>""" <EOL> item = super ( PictureOfTheDay , self ) . parse_entry ( entry ) <EOL> summary = lxml . html . fromstring ( entry . summary ) <EOL> image_node = select ( summary , '<STR_LIT>' ) <EOL> desc_node = select ( summary , '<STR_LIT>' ) <EOL> item [ '<STR_LIT>' ] = image_node . get ( '<STR_LIT>' ) <EOL> item [ '<STR_LIT:description>' ] = desc_node . text_content ( ) . strip ( ) <EOL> return item <EOL> class ArticleOfTheDay ( FeaturedFeedTriggerView ) : <EOL> """<STR_LIT>""" <EOL> feed = '<STR_LIT>' <EOL> wiki = '<STR_LIT>' <EOL> def parse_entry ( self , entry ) : <EOL> """<STR_LIT>""" <EOL> item = super ( ArticleOfTheDay , self ) . parse_entry ( entry ) <EOL> summary = lxml . html . fromstring ( entry . summary ) <EOL> read_more = select ( summary , '<STR_LIT>' ) <EOL> item [ '<STR_LIT:url>' ] = read_more . get ( '<STR_LIT>' ) <EOL> item [ '<STR_LIT:title>' ] = read_more . get ( '<STR_LIT:title>' ) <EOL> return item <EOL> class WordOfTheDay ( FeaturedFeedTriggerView ) : <EOL> """<STR_LIT>""" <EOL> feed = '<STR_LIT>' <EOL> wiki = '<STR_LIT>' <EOL> def parse_entry ( self , entry ) : <EOL> """<STR_LIT>""" <EOL> item = super ( WordOfTheDay , self ) . parse_entry ( entry ) <EOL> summary = lxml . html . fromstring ( entry . summary ) <EOL> div = summary . get_element_by_id ( '<STR_LIT>' ) <EOL> anchor = summary . get_element_by_id ( '<STR_LIT>' ) . getparent ( ) <EOL> item [ '<STR_LIT>' ] = anchor . get ( '<STR_LIT:title>' ) <EOL> item [ '<STR_LIT:url>' ] = anchor . get ( '<STR_LIT>' ) <EOL> item [ '<STR_LIT>' ] = anchor . getparent ( ) . getnext ( ) . text_content ( ) <EOL> item [ '<STR_LIT>' ] = div . text_content ( ) . strip ( ) <EOL> return item <EOL> for view_class in ( ArticleOfTheDay , PictureOfTheDay , WordOfTheDay ) : <EOL> slug = snake_case ( view_class . __name__ ) <EOL> app . add_url_rule ( '<STR_LIT>' % slug , <EOL> view_func = view_class . as_view ( slug ) ) </s>
