Skip to content

Commit

Permalink
Use has_children() instead of catching LeafKeyvalueError
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Nov 17, 2024
1 parent 34dc159 commit 00377a3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/srctools/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys

from srctools.filesys import FileSystemChain, RawFileSystem, VPKFileSystem
from srctools.keyvalues import Keyvalues, LeafKeyvalueError
from srctools.keyvalues import Keyvalues
from srctools.steam import find_app

__all__ = ['GINFO', 'Game', 'find_gameinfo']
Expand Down Expand Up @@ -133,9 +133,7 @@ def vpk_patch(p: Path) -> Path:
required = mount.bool("required", False)
# Selects if we want to mount the "mod_folder" key as a folder or omit
mountmoddir = mount.bool("mountmoddir", True)
enabled = mount.bool("enabled", True)

if not enabled: # Undocumented keyval
if not mount.bool("enabled", True): # Undocumented keyval
continue

try:
Expand All @@ -149,18 +147,16 @@ def vpk_patch(p: Path) -> Path:
continue

for child in mount:
# Ignore specified keys above
if child.name in ("head", "required", "enabled", "mountmoddir"):
continue # Ignore
continue
# Ignore any other leaf KVs.
if not child.has_children():
continue

# Else we're working with a mod folder
this_path = app_info.path / child.real_name

# If this is it cannot be iterated over, skip this keyvalue pair
try:
child.iter_tree()
except LeafKeyvalueError:
continue

for local_mount in child.iter_tree():
local_path = this_path / local_mount.value

Expand Down

0 comments on commit 00377a3

Please sign in to comment.