Skip to content

Commit

Permalink
Merge pull request #6 from Creatures-Developer-Network/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
KeyboardInterrupt authored Apr 15, 2020
2 parents 1ed1b8c + 398df24 commit b8a28d6
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 6 deletions.
5 changes: 5 additions & 0 deletions build_pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
python3 -m venv "venv"
venv/bin/python3 -m pip install --upgrade setuptools wheel
venv/bin/python3 setup.py sdist bdist_wheel

29 changes: 29 additions & 0 deletions examples/fix_corruptes_warped_creature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/python3
from prayer.prayer import Pray
from prayer.blocks import TagBlock
from sys import argv
import os

for file in argv[1:]:
with open(file, "rb") as f:
pray = Pray(f.read())
fixed_pray_file_data = bytes("PRAY", encoding="latin-1")
for block in pray.blocks:
print(block.type)
if block.type not in ["CREA", "GENE", "GLST", "PHOT", "warp"]:
print("YEPP Corrupted")
print(block.block_data.hex())
else:
if block.type == "warp":
tag_block = TagBlock(block.block_data)
for variable in tag_block.named_variables:
if type(variable[1]) == int:
print('\tINT Key: "%s" Value: %s' % variable)
elif type(variable[1]) == str:
print('\tSTR Key: "%s" Value: "%s"' % variable)
print("Block Type: %s\nBlock Name: %s" % (block.type, block.name))
fixed_pray_file_data += block.zblock_data
if file.endswith(".warp.detected_broken"):
print(file.rsplit(".", 1)[0])
with open(file.rsplit(".", 1)[0], "wb") as f:
f.write(fixed_pray_file_data)
3 changes: 2 additions & 1 deletion examples/pray_block_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
for block in pray.blocks:
print(block.type)
print("Block Type: %s\nBlock Name: %s" % (block.type, block.name))
with open("./%s-%s-%s.blk" % (os.path.basename(argv[1]), block.type, i), "wb") as f:
filename = "./%s-%s-%s.blk" % (os.path.basename(argv[1]), block.type, i)
with open(filename, "wb") as f:
f.write(block._block_data)
print("Wrote decompressed block data to %s" % filename)
i += 1
2 changes: 1 addition & 1 deletion prayer/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def block_data(self, block_data):

@property
def zblock_data(self):
return self._get_block_data(compress_data=true)
return self._get_block_data(compress_data=True)

@zblock_data.setter
def zblock_data(self, block_data):
Expand Down
5 changes: 2 additions & 3 deletions prayer/prayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@


class Pray:
# This list contains all the Blocks the given PRAY file contains.
blocks = list()

def __init__(self, pray=None):
# This list contains all the Blocks the given PRAY file contains.
self.blocks = list()
if pray is None:
data = bytes("PRAY", encoding="latin-1")
elif type(pray) == bytes:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="prayer",
version="0.1",
version="0.1.1",
description="Library, for working with PRAY files.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
4 changes: 4 additions & 0 deletions upload_pkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
python3 -m venv "venv"
venv/bin/python3 -m pip install --upgrade twine
venv/bin/python3 -m twine upload dist/*

0 comments on commit b8a28d6

Please sign in to comment.