Wrap game resource info from the server
Also add function to get the diff archive (for faster updating) Download function soon, although I can't make sure that the download function will work properly (like pause, resume download etc.)
This commit is contained in:
6
worthless/classes/installer/__init__.py
Normal file
6
worthless/classes/installer/__init__.py
Normal file
@ -0,0 +1,6 @@
|
||||
from worthless.classes.installer import resource, game, latest, diff, voicepack
|
||||
Resource = resource.Resource
|
||||
Game = game.Game
|
||||
Latest = latest.Latest
|
||||
Diff = diff.Diff
|
||||
Voicepack = voicepack.Voicepack
|
||||
21
worthless/classes/installer/diff.py
Normal file
21
worthless/classes/installer/diff.py
Normal file
@ -0,0 +1,21 @@
|
||||
from worthless.classes.installer.voicepack import Voicepack
|
||||
|
||||
|
||||
class Diff:
|
||||
def __init__(self, name, version, path, size, md5, is_recommended_update, voice_packs, raw):
|
||||
self.name = name
|
||||
self.version = version
|
||||
self.path = path
|
||||
self.size = size
|
||||
self.md5 = md5
|
||||
self.is_recommended_update = is_recommended_update
|
||||
self.voice_packs = voice_packs
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data):
|
||||
voice_packs = []
|
||||
for v in data['voice_packs']:
|
||||
voice_packs.append(Voicepack.from_dict(v))
|
||||
return Diff(data["name"], data["version"], data["path"], data["size"], data["md5"],
|
||||
data["is_recommended_update"], voice_packs, data)
|
||||
16
worthless/classes/installer/game.py
Normal file
16
worthless/classes/installer/game.py
Normal file
@ -0,0 +1,16 @@
|
||||
from worthless.classes.installer.latest import Latest
|
||||
from worthless.classes.installer.diff import Diff
|
||||
|
||||
|
||||
class Game:
|
||||
def __init__(self, latest, diffs, raw):
|
||||
self.latest = latest
|
||||
self.diffs = diffs
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data):
|
||||
diffs = []
|
||||
for diff in data['diffs']:
|
||||
diffs.append(Diff.from_dict(diff))
|
||||
return Game(Latest.from_dict(data['latest']), diffs, data)
|
||||
23
worthless/classes/installer/latest.py
Normal file
23
worthless/classes/installer/latest.py
Normal file
@ -0,0 +1,23 @@
|
||||
from worthless.classes.installer.voicepack import Voicepack
|
||||
|
||||
|
||||
class Latest:
|
||||
def __init__(self, name, version, path, size, md5, entry, voice_packs, decompressed_path, segments, raw):
|
||||
self.name = name
|
||||
self.version = version
|
||||
self.path = path
|
||||
self.size = size
|
||||
self.md5 = md5
|
||||
self.entry = entry
|
||||
self.voice_packs = voice_packs
|
||||
self.decompressed_path = decompressed_path
|
||||
self.segments = segments
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data):
|
||||
voice_packs = []
|
||||
for v in data['voice_packs']:
|
||||
voice_packs.append(Voicepack.from_dict(v))
|
||||
return Latest(data["name"], data["version"], data["path"], data["size"], data["md5"], data["entry"],
|
||||
voice_packs, data["decompressed_path"], data["segments"], data)
|
||||
30
worthless/classes/installer/resource.py
Normal file
30
worthless/classes/installer/resource.py
Normal file
@ -0,0 +1,30 @@
|
||||
from worthless.classes.installer.game import Game
|
||||
|
||||
|
||||
class Resource:
|
||||
"""Contains the game resource information.
|
||||
|
||||
Everything except `game` is not wrapped yet
|
||||
|
||||
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, game, plugin, web_url, force_update, pre_download_game, deprecated_packages, sdk, raw):
|
||||
self.game = game
|
||||
self.plugin = plugin
|
||||
self.web_url = web_url
|
||||
self.force_update = force_update
|
||||
self.pre_download_game = pre_download_game
|
||||
self.deprecated_packages = deprecated_packages
|
||||
self.sdk = sdk
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data):
|
||||
return Resource(Game.from_dict(data['game']), data['plugin'], data['web_url'], data['force_update'],
|
||||
data['pre_download_game'], data['deprecated_packages'], data['sdk'], data)
|
||||
12
worthless/classes/installer/voicepack.py
Normal file
12
worthless/classes/installer/voicepack.py
Normal file
@ -0,0 +1,12 @@
|
||||
class Voicepack:
|
||||
def __init__(self, language, name, path, size, md5, raw):
|
||||
self.language = language
|
||||
self.name = name
|
||||
self.path = path
|
||||
self.size = size
|
||||
self.md5 = md5
|
||||
self.raw = raw
|
||||
|
||||
@staticmethod
|
||||
def from_dict(data):
|
||||
return Voicepack(data["language"], data["name"], data["path"], data["size"], data["md5"], data)
|
||||
Reference in New Issue
Block a user