Support chinese variant, QQ object in launcher and some code optimizations

This commit is contained in:
2022-02-16 00:49:33 +07:00
parent 048a7ac9d0
commit c22918673b
19 changed files with 389 additions and 58 deletions

View File

@ -1,16 +1,33 @@
from worthless.classes.launcher import background, banner, iconbutton, post
from worthless.classes.launcher import background, banner, iconbutton, post, qq
Background = background.Background
Banner = banner.Banner
IconButton = iconbutton.IconButton
Post = post.Post
QQ = qq.QQ
class Info:
def __init__(self, lc_background: Background, lc_banner: list[Banner], icon: list[IconButton], lc_post: list[Post]):
"""Contains the launcher information
Note that QQ is not wrapped due to not having access to the chinese yuanshen launcher.
You can contribute to the project if you want :D
Attributes:
- :class:`worthless.classes.launcher.background.Background` background: The launcher background information.
- :class:`worthless.classes.launcher.banner.Banner` banner: The launcher banner information.
- :class:`worthless.classes.launcher.iconbutton.IconButton` icon: The launcher icon buttons information.
- :class:`worthless.classes.launcher.qq.QQ` post: The launcher QQ posts information.
- :class:`dict` raw: The launcher raw information.
"""
def __init__(self, lc_background: Background, lc_banner: list[Banner], icon: list[IconButton], lc_post: list[Post],
lc_qq: list[QQ], raw: dict):
self.background = lc_background
self.banner = lc_banner
self.icon = icon
self.post = lc_post
self.qq = lc_qq
self.raw = raw
@staticmethod
def from_dict(data):
@ -24,5 +41,8 @@ class Info:
lc_post = []
for p in data["post"]:
lc_post.append(Post.from_dict(p))
return Info(bg, lc_banner, lc_icon, lc_post)
lc_qq = []
for q in data["qq"]:
lc_qq.append(QQ.from_dict(q))
return Info(bg, lc_banner, lc_icon, lc_post, lc_qq, data)