Download backend/models/source.py from Zelyanoth/Lin: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/Zelyanoth/Lin/resolve/2f9f089a2766b29cc75650ca36b9cdd9e615cfb0/backend/models/source.py
- Command line
-
hf download hf://spaces/Zelyanoth/Lin@2f9f089a2766b29cc75650ca36b9cdd9e615cfb0/backend/models/source.py
-
curl -L -o source.py https://huggingface.co/spaces/Zelyanoth/Lin/resolve/2f9f089a2766b29cc75650ca36b9cdd9e615cfb0/backend/models/source.py
1.29 kB
| from dataclasses import dataclass | |
| from typing import Optional | |
| from datetime import datetime | |
| class Source: | |
| """Source model representing an RSS source.""" | |
| id: str | |
| user_id: str | |
| source: str | |
| category: Optional[str] = None | |
| last_update: Optional[datetime] = None | |
| created_at: Optional[datetime] = None | |
| def from_dict(cls, data: dict): | |
| """Create a Source instance from a dictionary.""" | |
| return cls( | |
| id=data['id'], | |
| user_id=data['user_id'], | |
| source=data['source'], | |
| category=data.get('category'), | |
| last_update=datetime.fromisoformat(data['last_update'].replace('Z', '+00:00')) if data.get('last_update') else None, | |
| created_at=datetime.fromisoformat(data['created_at'].replace('Z', '+00:00')) if data.get('created_at') else None | |
| ) | |
| def to_dict(self): | |
| """Convert Source instance to dictionary.""" | |
| return { | |
| 'id': self.id, | |
| 'user_id': self.user_id, | |
| 'source': self.source, | |
| 'category': self.category, | |
| 'last_update': self.last_update.isoformat() if self.last_update else None, | |
| 'created_at': self.created_at.isoformat() if self.created_at else None | |
| } |