Update tests
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
from worthless.classes.launcher import background, banner, iconbutton, iconotherlink, info, post
|
||||
Background = background.Background
|
||||
Banner = banner.Banner
|
||||
IconButton = iconbutton.IconButton
|
||||
IconOtherLink = iconotherlink.IconOtherLink
|
||||
Info = info.Info
|
||||
Post = post.Post
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from worthless.classes.launcher.launchericonotherlink import IconOtherLink
|
||||
from worthless.classes.launcher.iconotherlink import IconOtherLink
|
||||
|
||||
|
||||
class IconButton:
|
||||
|
||||
@ -1,3 +1,28 @@
|
||||
class LauncherInfo:
|
||||
def __init__(self):
|
||||
pass
|
||||
from worthless.classes.launcher import background, banner, iconbutton, post
|
||||
Background = background.Background
|
||||
Banner = banner.Banner
|
||||
IconButton = iconbutton.IconButton
|
||||
Post = post.Post
|
||||
|
||||
|
||||
class Info:
|
||||
def __init__(self, lc_background: Background, lc_banner: list[Banner], icon: list[IconButton], lc_post: list[Post]):
|
||||
self.background = lc_background
|
||||
self.banner = lc_banner
|
||||
self.icon = icon
|
||||
self.post = lc_post
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data):
|
||||
bg = Background.from_dict(data["adv"])
|
||||
lc_banner = []
|
||||
for b in data["banner"]:
|
||||
lc_banner.append(Banner.from_dict(b))
|
||||
lc_icon = []
|
||||
for i in data["icon"]:
|
||||
lc_icon.append(IconButton.from_dict(i))
|
||||
lc_post = []
|
||||
for p in data["post"]:
|
||||
lc_post.append(Post.from_dict(p))
|
||||
return Info(bg, lc_banner, lc_icon, lc_post)
|
||||
|
||||
|
||||
@ -1,29 +1,38 @@
|
||||
class Banner:
|
||||
"""Contains a launcher banner information
|
||||
class Post:
|
||||
"""Contains a launcher post information
|
||||
|
||||
Note that the banner name is in chinese, so you may not find this variable useful.
|
||||
Also, the banner has a variable called `order`, you can use that to sort the banner
|
||||
like the official launcher does.
|
||||
The `type` variable can be POST_TYPE_ANNOUNCE, POST_TYPE_ACTIVITY and POST_TYPE_INFO
|
||||
where announce is an announcement, activity is an activity/event and info is an information.
|
||||
|
||||
The `show_time` variable is the time in DD/MM format when the post will be shown.
|
||||
|
||||
Also, `tittle` is not my typo, and it's the server intention (probably there are clients
|
||||
where their developers wrote `tittle` instead of `title`), and the post has a variable
|
||||
called `order`, you can use that to sort the post like the official launcher does.
|
||||
|
||||
Attributes:
|
||||
|
||||
- :class:`str` banner_id: The launcher banner id.
|
||||
- :class:`str` name: The banner name.
|
||||
- :class:`str` img: The banner image url.
|
||||
- :class:`str` url: The banner target url.
|
||||
- :class:`str` order: The banner order.
|
||||
- :class:`str` name: The banner name.
|
||||
- :class:`str` post_id: The launcher post id.
|
||||
- :class:`str` type: The post type, as explained above.
|
||||
- :class:`str` tittle: The post title.
|
||||
- :class:`str` url: The post target url.
|
||||
- :class:`str` show_time: The time when the post will be shown.
|
||||
- :class:`str` order: The post order.
|
||||
- :class:`str` title: The post title.
|
||||
- :class:`dict` raw: The banner raw information.
|
||||
"""
|
||||
def __init__(self, banner_id, name, img, url, order, raw):
|
||||
self.banner_id = banner_id
|
||||
self.name = name
|
||||
self.img = img
|
||||
def __init__(self, post_id, post_type, tittle, url, show_time, order, title, raw):
|
||||
self.post_id = post_id
|
||||
self.type = post_type # Shadow built-in name `type`
|
||||
self.tittle = tittle
|
||||
self.url = url
|
||||
self.show_time = show_time
|
||||
self.order = order
|
||||
self.title = title
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data) -> 'Banner':
|
||||
"""Creates a launcher banner from a dictionary."""
|
||||
return Banner(data["banner_id"], data["name"], data["img"], data["url"], data["order"], data)
|
||||
def from_dict(data) -> 'Post':
|
||||
"""Creates a launcher post from a dictionary."""
|
||||
return Post(data["post_id"], data["type"], data["tittle"], data["url"],
|
||||
data["show_time"], data["order"], data["title"], data)
|
||||
|
||||
Reference in New Issue
Block a user