Ejemplo n.º 1
0
 def test_pack_unpack(self):
     files = [
         {
             "version": 0,
             "file_entries": []
         },
         {
             "version":
             0,
             "file_entries": [{
                 "file_type": 1,
                 "compression_type": 0,
                 "data": b"The Game"
             }, {
                 "file_type": 1,
                 "compression_type": 0,
                 "data": b"Ha, you lost it!"
             }, {
                 "file_type": 0,
                 "compression_type": 1,
                 "data": b"\0Test test test \0"
             }]
         },
     ]
     for f in files:
         self.assertDictEqual(f,
                              unpack.unpack_archive(pack.pack_archive(f)))
Ejemplo n.º 2
0
 def test_pack_unpack(self):
     files = [
         b'WRPGPIAF\xec\xbbKU\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
         b'WRPGPIAFI\xe0\x83\x06\x94vZ\x83\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x07\x00\x00\x00\x00TheGame'
     ]
     for f in files:
         self.assertEqual(f, pack.pack_archive(unpack.unpack_archive(f)))
Ejemplo n.º 3
0
def bundle(files, path_out):
    for f in files["file_entries"]:
        if 'path' in f:
            with open(f["path"], "rb") as o:
                f["data"] = o.read()
                print(f['file_name'])
        f["file_name"] = f["file_name"].encode('ascii')
    out = pack.pack_archive(files)
    f = open(path_out, "wb+")
    f.write(out)
Ejemplo n.º 4
0
def bundle(files, path_out):
    for f in files["file_entries"]:
        if 'path' in f:
            with open(f["path"], "rb") as o:
                f["data"] = o.read()
                print(f['file_name'])
        f["file_name"] = f["file_name"].encode('ascii')
    out = pack.pack_archive(files)
    f = open(path_out, "wb+")
    f.write(out)