Skip to content

Commit a63c581

Browse files
authored
Update sorted() call for Python 3.6+. Fallback index for unrecognized types. (K0lb3#132)
1 parent cf3c2bb commit a63c581

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎UnityPy/tools/extractor.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ def extract_assets(
9292
def defaulted_export_index(type: ClassIDType):
9393
try:
9494
return export_types_keys.index(type)
95-
except IndexError:
95+
except (IndexError, ValueError):
9696
return 999
9797

9898
if use_container:
99-
container = sorted(env.container, lambda x: defaulted_export_index(x[1].type))
99+
container = sorted(env.container, key=lambda x: defaulted_export_index(x[1].type))
100100
for obj_path, obj in container:
101101
# the check of the various sub directories is required to avoid // in the path
102102
obj_dest = os.path.join(
@@ -114,7 +114,7 @@ def defaulted_export_index(type: ClassIDType):
114114
)
115115

116116
else:
117-
objects = sorted(env.objects, lambda x: defaulted_export_index(x.type))
117+
objects = sorted(env.objects, key=lambda x: defaulted_export_index(x.type))
118118
for obj in objects:
119119
if obj.path_id not in exported:
120120
exported.extend(

0 commit comments

Comments
 (0)