This repository has been archived on 2025-01-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
blog-software/article.py
2024-05-19 10:26:52 +02:00

18 lines
No EOL
414 B
Python

from dataclasses import dataclass
from io import TextIOWrapper
from os import sep
@dataclass
class Article:
id: str
title: str
summary: str
content: str
def read_article_file(file: TextIOWrapper) -> Article:
id = file.name.split(sep)[-1].split('.')[0]
title = file.readline()
summary = file.readline()
content = file.read().strip()
return Article(id, title, summary, content)