Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions UnityPy/helpers/Tpk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from enum import IntEnum, IntFlag
from importlib.resources import open_binary
from io import BytesIO
from struct import Struct
from typing import Any, Dict, List, Optional, Tuple, TypeVar
Expand All @@ -18,8 +17,19 @@


def init():
with open_binary("UnityPy.resources", "lzma.tpk") as f:
data = f.read()
try:
from importlib.resources import files

def open_resource(package, resource):
return files(package).joinpath(resource).open("rb").read()

except ImportError:
from importlib.resources import open_binary

def open_resource(package, resource):
return open_binary(package, resource).read()

data = open_resource("UnityPy.resources", "lzma.tpk")

global TPKTYPETREE
with BytesIO(data) as stream:
Expand Down