-
Notifications
You must be signed in to change notification settings - Fork 3
/
schema.py
62 lines (53 loc) · 1.52 KB
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import json
from typing import List, Optional
from dataclasses import dataclass, field, asdict
# from datafiles import datafile
from urllib.parse import urlparse
# @datafile("data/{self.domain}.json")
@dataclass(init=True)
class SiteInfoItem:
url: str = ''
name: Optional[str] = ''
domain: Optional[str] = ''
icon: Optional[str] = ''
rss: Optional[str] = ''
generator: Optional[str] = ''
description: Optional[str] = ''
friends: Optional[List[str]] = field(default_factory=list)
# not use
host_server: Optional[str] = ''
comment_server: Optional[str] = ''
# features
tld: Optional[str] = ''
sld: Optional[str] = ''
len_friends: int = 0
has_rss: bool = False
has_generator: bool = False
has_archive: bool = False
has_tag: bool = False
has_category: bool = False
has_about: bool = False
has_theme: bool = False
has_zh_text: bool = False
has_blog_text: bool = False
# y
is_zh_i9t_blog: bool = True
def __post_init__(self):
if not self.domain:
self.domain = urlparse(self.url).netloc
def save_to_file(self, f):
r = asdict(self)
# print(r)
json.dump(r, f)
print(f"update:{self.domain}")
if __name__ == "__main__":
site = SiteInfoItem(url="https://gine.me")
site.name = "Mayne's Blog"
site.domain = 'gine.me'
site.rss = "/feed"
site.host_server = 'netlify'
site.comment_server = 'diqus'
site.friends = [
'https://ruterly.com'
]
# site.save_to_file()