bookwyrm/bookwyrm/activitypub/book.py

68 lines
1.3 KiB
Python
Raw Normal View History

''' book and author data '''
from dataclasses import dataclass, field
from typing import List
2020-03-28 02:52:05 +00:00
from .base_activity import ActivityObject, Image
2020-03-28 02:52:05 +00:00
@dataclass(init=False)
class Book(ActivityObject):
''' serializes an edition or work, abstract '''
authors: List[str]
first_published_date: str
published_date: str
2020-03-28 04:28:52 +00:00
title: str
sort_title: str
subtitle: str
description: str
languages: List[str]
series: str
series_number: str
subjects: List[str]
subject_places: List[str]
2020-03-28 04:28:52 +00:00
openlibrary_key: str
librarything_key: str
goodreads_key: str
2020-03-28 02:52:05 +00:00
attachment: List[Image] = field(default=lambda: [])
type: str = 'Book'
2020-03-28 02:52:05 +00:00
@dataclass(init=False)
class Edition(Book):
''' Edition instance of a book object '''
isbn_10: str
isbn_13: str
oclc_number: str
asin: str
pages: str
physical_format: str
publishers: List[str]
2020-03-28 02:52:05 +00:00
work: str
type: str = 'Edition'
2020-03-28 02:52:05 +00:00
2020-05-10 04:52:13 +00:00
@dataclass(init=False)
class Work(Book):
''' work instance of a book object '''
lccn: str
editions: List[str]
type: str = 'Work'
2020-05-10 04:52:13 +00:00
@dataclass(init=False)
class Author(ActivityObject):
''' author of a book '''
url: str
name: str
born: str
died: str
aliases: str
bio: str
openlibrary_key: str
wikipedia_link: str
type: str = 'Person'