68 lines
1.4 KiB
Python
68 lines
1.4 KiB
Python
from dateutil import parser
|
|
from dataclasses import dataclass
|
|
from datetime import datetime
|
|
import bleach
|
|
|
|
BLEACH_CONFIG = {
|
|
'tags': ['br', 'font', 'b', 'i', 'u', 'loc', 'a'],
|
|
'attributes': ['href']
|
|
}
|
|
|
|
|
|
@dataclass
|
|
class Alliance:
|
|
id: int
|
|
name: str
|
|
creator_id: int
|
|
creator_corporation_id: int
|
|
ticker: str
|
|
date_founded: datetime
|
|
executor_corporation_id: int
|
|
faction_id: int = None
|
|
|
|
def __post_init__(self):
|
|
if self.date_founded:
|
|
self.date_founded = parser.parse(self.date_founded)
|
|
|
|
|
|
@dataclass
|
|
class Corporation:
|
|
id: int
|
|
name: str
|
|
ticker: str
|
|
member_count: int
|
|
ceo_id: int
|
|
tax_rate: int
|
|
creator_id: int
|
|
description: str
|
|
date_founded: datetime
|
|
home_station_id: int
|
|
shares: int
|
|
alliance_id: int = None
|
|
faction_id: int = None
|
|
url: str = ''
|
|
|
|
def __post_init__(self):
|
|
if self.date_founded:
|
|
self.date_founded = parser.parse(self.date_founded)
|
|
self.description = bleach.clean(self.description, **BLEACH_CONFIG)
|
|
|
|
|
|
@dataclass
|
|
class Character:
|
|
id: int
|
|
corporation_id: int
|
|
name: str
|
|
gender: str
|
|
race_id: int
|
|
bloodline_id: int
|
|
description: str
|
|
ancestry_id: int
|
|
security_status: float
|
|
birthday: datetime
|
|
|
|
def __post_init__(self):
|
|
if self.birthday:
|
|
self.birthday = parser.parse(self.birthday)
|
|
self.description = bleach.clean(self.description, **BLEACH_CONFIG)
|