コード例 #1
0
def _dict_to_news(d):
    news = News()

    news.date = d['date']
    news.title = d['title']
    news.thumbnailUrl = d['thumbnailUrl']
    news.questions.extend([_dict_to_question(qd) for qd in d['questions']])

    return news
コード例 #2
0
ファイル: mongo.py プロジェクト: izzyleung/ZhihuDailyPurify
def _dict_to_news(d):
    news = News()

    news.date = d['date']
    news.title = d['title']
    news.thumbnailUrl = d['thumbnailUrl']
    news.questions.extend([_dict_to_question(qd) for qd in d['questions']])

    return news
コード例 #3
0
ファイル: official.py プロジェクト: helloWotu/AndroidStudy
    def to_news(self, story):
        questions = ZhihuDailyOfficial._questions(story)

        news = News()

        news.date = self.date
        news.title = story.metadata.title
        news.thumbnailUrl = story.metadata.thumbnail_url
        news.questions.extend([q for q in questions if q])

        return news if news.questions else None
コード例 #4
0
ファイル: official.py プロジェクト: youjiti/ZhihuDailyPurify
    def to_news(self, pair):
        story, document = pair
        questions = ZhihuDailyOfficial._questions(pair)

        news = News()

        news.date = self.date
        news.title = story.title
        news.thumbnailUrl = story.thumbnail_url
        news.questions.extend([q for q in questions if q])

        return news if news.questions else None
コード例 #5
0
def to_news(pair, date):
    story, document = pair
    elements = _get_question_elements(document)

    news = News()

    news.date = date
    news.title = story.title
    news.thumbnailUrl = story.thumbnail_url
    news.questions.extend(
        filter(lambda q: _is_question_url_valid(q.url),
               [_to_question(element, story) for element in elements]))

    return news
コード例 #6
0
def _to_news(pair, date):
    story, document = pair
    question_elements = _get_question_elements(document)

    news = News()

    news.date = date
    news.title = story.title
    news.thumbnailUrl = story.thumbnail_url
    news.questions.extend(
        filter(lambda q: _is_question_url_valid(q.url), [
            _to_question(question_element)
            for question_element in question_elements
        ]))

    for question in news.questions:
        question.title = question.title or story.title

    return news