Exemple #1
0
def article_to_json(article: Article):
    static_fields = article.static_fields() - {
        "id", "project_id", "project", "properties"
    }
    static_fields = {fn: getattr(article, fn) for fn in static_fields}
    return dict(static_fields,
                properties=dict(article.get_properties().items()))
Exemple #2
0
def article_to_json(article: Article) -> Dict[str, Union[str, int, float, datetime.datetime]]:
    return {
        "title": article.title,
        "text": article.text,
        "hash": article.hash,
        "parent_hash": article.parent_hash,
        "url": article.url,
        "date": article.date,
        "properties": dict(article.get_properties())
    }
Exemple #3
0
def article_to_json(
        article: Article
) -> Dict[str, Union[str, int, float, datetime.datetime]]:
    return {
        "title": article.title,
        "text": article.text,
        "hash": article.hash,
        "parent_hash": article.parent_hash,
        "url": article.url,
        "date": article.date,
        "properties": dict(article.get_properties())
    }