Object-oriented programming
All launcher functions are now return an object instead of a dict
This commit is contained in:
parent
8f32241191
commit
a7ddd0c49a
1
_trial_temp.lock
Symbolic link
1
_trial_temp.lock
Symbolic link
@ -0,0 +1 @@
|
||||
15389
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
aiohttp==3.8.1
|
0
worthless/classes/__init__.py
Normal file
0
worthless/classes/__init__.py
Normal file
0
worthless/classes/launcher/__init__.py
Normal file
0
worthless/classes/launcher/__init__.py
Normal file
34
worthless/classes/launcher/background.py
Normal file
34
worthless/classes/launcher/background.py
Normal file
@ -0,0 +1,34 @@
|
||||
class Background:
|
||||
"""Contains the launcher background information
|
||||
|
||||
Note that the `background` variable is an url to the background image,
|
||||
while the `url` variable contains an empty string, so it seems that the
|
||||
`url` and `icon` variables are used by the official launcher itself.
|
||||
|
||||
Also, the launcher background checksum is using an algorithm which I
|
||||
haven't found out yet, so you better not rely on it but instead rely
|
||||
on the url name which contains a md5 sum in the first part of the name.
|
||||
|
||||
Attributes:
|
||||
|
||||
- :class:`str` background: The launcher background url.
|
||||
- :class:`str` icon: The icon url.
|
||||
- :class:`str` url: The url variable.
|
||||
- :class:`str` version: The launcher background version.
|
||||
- :class:`str` bg_checksum: The launcher background checksum.
|
||||
- :class:`dict` raw: The launcher background raw information in dict.
|
||||
"""
|
||||
def __init__(self, background, icon, url, version, bg_checksum, raw):
|
||||
"""Inits the launcher background class"""
|
||||
self.background = background
|
||||
self.icon = icon
|
||||
self.url = url
|
||||
self.version = version
|
||||
self.bg_checksum = bg_checksum
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data) -> 'Background':
|
||||
"""Creates a launcher background from a dictionary."""
|
||||
return Background(data["background"], data["icon"], data["url"],
|
||||
data["version"], data["bg_checksum"], data)
|
29
worthless/classes/launcher/banner.py
Normal file
29
worthless/classes/launcher/banner.py
Normal file
@ -0,0 +1,29 @@
|
||||
class Banner:
|
||||
"""Contains a launcher banner 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.
|
||||
|
||||
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:`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
|
||||
self.url = url
|
||||
self.order = order
|
||||
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)
|
42
worthless/classes/launcher/iconbutton.py
Normal file
42
worthless/classes/launcher/iconbutton.py
Normal file
@ -0,0 +1,42 @@
|
||||
from worthless.classes.launcher.launchericonotherlink import IconOtherLink
|
||||
|
||||
|
||||
class IconButton:
|
||||
"""Contains a launcher icon button information
|
||||
|
||||
The `qr_img`, `qr_desc` variables are not used in the official launcher
|
||||
(since it's empty)
|
||||
|
||||
Attributes:
|
||||
|
||||
- :class:`str` icon_id: The icon id.
|
||||
- :class:`str` img: The icon url.
|
||||
- :class:`str` tittle: The icon title.
|
||||
- :class:`str` url: The icon target url.
|
||||
- :class:`str` qr_img: The QR code url.
|
||||
- :class:`str` qr_desc: The QR code description.
|
||||
- :class:`str` img_hover: The icon url when hovered over.
|
||||
- :class:`dict[LauncherIconOtherLink]` other_links: Other links in the button.
|
||||
- :class:`dict` raw: The launcher background raw information in dict.
|
||||
"""
|
||||
def __init__(self, icon_id, img, tittle, url, qr_img, qr_desc, img_hover, other_links, raw):
|
||||
"""Inits the launcher icon class"""
|
||||
self.icon_id = icon_id
|
||||
self.img = img
|
||||
self.tittle = tittle
|
||||
self.url = url
|
||||
self.qr_img = qr_img
|
||||
self.qr_desc = qr_desc
|
||||
self.img_hover = img_hover
|
||||
self.other_links = other_links
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data) -> 'IconButton':
|
||||
"""Creates a launcher background from a dictionary."""
|
||||
other_links = []
|
||||
for link in data['other_links']:
|
||||
other_links.append(IconOtherLink.from_dict(link))
|
||||
return IconButton(data["icon_id"], data["img"], data["tittle"], data["url"], data["qr_img"],
|
||||
data["qr_desc"], data["img_hover"], other_links, data)
|
||||
|
9
worthless/classes/launcher/iconotherlink.py
Normal file
9
worthless/classes/launcher/iconotherlink.py
Normal file
@ -0,0 +1,9 @@
|
||||
class IconOtherLink:
|
||||
def __init__(self, title, url):
|
||||
self.title = title
|
||||
self.url = url
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data) -> 'IconOtherLink':
|
||||
"""Creates a launcher icon other link from a dictionary."""
|
||||
return IconOtherLink(data["title"], data["url"])
|
3
worthless/classes/launcher/info.py
Normal file
3
worthless/classes/launcher/info.py
Normal file
@ -0,0 +1,3 @@
|
||||
class LauncherInfo:
|
||||
def __init__(self):
|
||||
pass
|
29
worthless/classes/launcher/post.py
Normal file
29
worthless/classes/launcher/post.py
Normal file
@ -0,0 +1,29 @@
|
||||
class Banner:
|
||||
"""Contains a launcher banner 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.
|
||||
|
||||
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:`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
|
||||
self.url = url
|
||||
self.order = order
|
||||
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)
|
0
worthless/patcher.py
Normal file
0
worthless/patcher.py
Normal file
1
worthless/requirements.txt
Normal file
1
worthless/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
aiohttp==3.8.1
|
Loading…
Reference in New Issue
Block a user