mirror of
https://github.com/Omni-guides/Jackify.git
synced 2026-06-08 00:07:45 +02:00
Sync from development - prepare for v0.5.0
This commit is contained in:
34
jackify/backend/utils/cc_content_detector.py
Normal file
34
jackify/backend/utils/cc_content_detector.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
Detects Creation Club / Anniversary Edition content missing errors in engine output.
|
||||
"""
|
||||
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
# Matches CC content file names: ccXXXsse001-name.bsa/esm/esl/esp, ccXXXfo4001-name.ba2, etc.
|
||||
# No leading \b — filenames often appear with a Data_ prefix (Data_ccbgssse019-...)
|
||||
# where _ is a word char and would prevent \b from matching.
|
||||
_CC_FILE_RE = re.compile(
|
||||
r'cc[a-z]{2,8}\d{3,4}[-\w]*\.(?:bsa|esm|esl|esp|ba2)',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
_ERROR_WORDS = frozenset((
|
||||
'missing', 'required', 'failed', 'unable', 'cannot', 'error', 'not found',
|
||||
))
|
||||
|
||||
|
||||
def is_cc_content_error(line: str) -> bool:
|
||||
"""Return True if line indicates a missing CC/AE content file in an error context."""
|
||||
if not line:
|
||||
return False
|
||||
normalized = line.strip().lower()
|
||||
if not _CC_FILE_RE.search(normalized):
|
||||
return False
|
||||
return any(w in normalized for w in _ERROR_WORDS)
|
||||
|
||||
|
||||
def extract_cc_filename(line: str) -> Optional[str]:
|
||||
"""Return the CC filename from a line, or None if not found."""
|
||||
m = _CC_FILE_RE.search(line)
|
||||
return m.group(0) if m else None
|
||||
@@ -1,8 +1,10 @@
|
||||
import json
|
||||
import re
|
||||
from typing import Optional
|
||||
from jackify.shared.errors import (
|
||||
JackifyError, InstallError, OAuthError,
|
||||
oauth_expired, wabbajack_install_failed, format_technical_context,
|
||||
game_not_found_for_modlist,
|
||||
)
|
||||
|
||||
|
||||
@@ -12,7 +14,29 @@ def _ctx_detail(ctx: dict) -> Optional[str]:
|
||||
return format_technical_context(context=ctx)
|
||||
|
||||
|
||||
def _engine_error(msg: str, ctx: dict) -> InstallError:
|
||||
"""Map generic engine_error payloads to user-visible, actionable InstallError variants."""
|
||||
text = (msg or "").strip()
|
||||
match = re.search(r"can't find game\s+([A-Za-z0-9_:-]+)", text, flags=re.IGNORECASE)
|
||||
if match:
|
||||
game_name = match.group(1)
|
||||
return game_not_found_for_modlist(game_name, detail=text)
|
||||
|
||||
return InstallError(
|
||||
"Install Engine Error",
|
||||
text or "An install engine error occurred.",
|
||||
suggestion="Review the error message and retry after correcting the reported issue.",
|
||||
solutions=[
|
||||
"Check the exact error message shown above and fix the prerequisite it mentions.",
|
||||
"Retry the install after restarting Steam.",
|
||||
"If this persists, check Modlist_Install_workflow.log for the same error text.",
|
||||
],
|
||||
technical=_ctx_detail(ctx),
|
||||
)
|
||||
|
||||
|
||||
_TYPE_MAP = {
|
||||
"engine_error": _engine_error,
|
||||
"auth_failed": lambda msg, ctx: oauth_expired(),
|
||||
"premium_required": lambda msg, ctx: InstallError(
|
||||
"Nexus Premium Required",
|
||||
|
||||
Reference in New Issue
Block a user