Skip to content

Commit

Permalink
supported unpack anything
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryQuan committed Oct 22, 2022
1 parent 6f7fc5b commit bd7971e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
if __name__ == '__main__':
unpack = WoWsUnpack('C:\Games\World_of_Warships')
unpack.search('*prill*')
unpack.unpackGameGUI()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wowsunpack
wowsunpack==0.1.7
pyinstaller
build
twine
16 changes: 12 additions & 4 deletions src/wowsunpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def _call(self, command: str):
"""
Call wowsunpack.exe and make sure it was successful
"""
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# set shell to true for the pipe to work (writing to a file)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = p.communicate()
output = out.decode('utf-8')
if 'ERROR' in output or p.returncode != 0:
Expand Down Expand Up @@ -122,26 +123,33 @@ def decodeGameParams(self):
print("done decoding game params\n")
else:
raise FileNotFoundError("GameParams.data not found")

def unpack(self, query: str):
"""
Unpack anything with the given query
"""
self._call(self._wowsunpack() + ' -I ' + query)
print("done unpacking {}\n".format(query))

def unpackGameIcons(self):
"""
Unpack game icons from the bin folder
"""
self._call(self._wowsunpack() + ' -I gui/*.png -I gui/*.jpg')
self.unpack('gui/*.png -I gui/*.jpg')
print("done unpacking game icons\n")

def unpackGameGUI(self):
"""
Unpack game GUI from the bin folder
"""
self._call(self._wowsunpack() + ' -I gui/*')
self.unpack('gui/*')
print("done unpacking game GUI\n")

def unpackGameMaps(self):
"""
Unpack game maps from the bin folder
"""
self._call(self._wowsunpack() + ' -I spaces/*')
self.unpack('spaces/*')
print("done unpacking game icons\n")

def decodeLanguages(self):
Expand Down
6 changes: 6 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from wowsunpack import WoWsUnpack

if __name__ == '__main__':
unpack = WoWsUnpack('C:\Games\World_of_Warships')
unpack.search('*prill*')

import sys
sys.argv = ['', '--lang', '--icons', '--maps', '--assets']
import wowsunpack.__main__

0 comments on commit bd7971e

Please sign in to comment.