2025-08-20 11:54:40 +01:00

47 lines
1.6 KiB
Python

from dataclasses import dataclass
import random
from faker import Faker
@dataclass
class NetworkingSize:
request_size: int = 0
response_size: int = 0
def get_size_from_dict(data: dict):
return NetworkingSize(
request_size=data.get('request_bytes', 0),
response_size=data.get('response_bytes', 0)
)
def generate_random_book_data(count: int) -> list[dict]:
fake = Faker("en_GB")
return [
{
# 'id': book_id,
'isbn': fake.isbn13(separator='-'),
'barcode': fake.ean(length=13),
'title': fake.sentence(nb_words=6),
'subtitle': fake.sentence(nb_words=3),
'author': fake.name(),
'translator': fake.name(),
'editor': fake.name(),
'publisher': fake.company(),
'publication_date': random.randint(-2190472676, 1754206067),
'edition': fake.word(),
'pages': random.randint(100, 1000),
'language': random.choice(['English', 'Français', 'Deutsch']),
'category_id': random.randint(1, 100),
'subject': fake.word(),
'keywords': ", ".join(fake.words(nb=5, unique=True, ext_word_list=None)),
'description': fake.text(max_nb_chars=200),
'abstract': fake.text(max_nb_chars=100),
'format': random.choice(['16mo', '8vo', '4to', 'Folio', 'Quarto']),
'binding': random.choice(['expensive', 'cheap', 'paperback', 'hardcover']),
'weight': random.uniform(100, 2000),
'cover_image': "https://example.com/cover_image.jpg"
} for _ in range(count)
]