Answer stability round 3: 0 🔴, 1 🟡 (0 misread); test that a size after the image's command is no limit; name given's regex parameter pattern

This commit is contained in:
2026-10-24 00:47:57 +02:00
parent e17ed74fc2
commit a622d19280
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -39,10 +39,10 @@ def unlimited(arguments: list[str]) -> bool:
return subcommand in STARTS_CONTAINER and not limited and not helped(arguments, subcommand)
def given(arguments: list[str], options: tuple[str, ...], value: str) -> bool:
"""Whether the arguments give one of the options a value value matches, as its next word or attached, as in -m4g or --memory=4g."""
attached = re.compile("|".join(re.escape(option) + ("" if len(option) == 2 else "=") + f"(?:{value})" for option in options))
return any(attached.fullmatch(word) or (word in options and re.fullmatch(value, following)) for word, following in zip(arguments, [*arguments[1:], ""]))
def given(arguments: list[str], options: tuple[str, ...], pattern: str) -> bool:
"""Whether the arguments give one of the options a value pattern matches, as its next word or attached, as in -m4g or --memory=4g."""
attached = re.compile("|".join(re.escape(option) + ("" if len(option) == 2 else "=") + f"(?:{pattern})" for option in options))
return any(attached.fullmatch(word) or (word in options and re.fullmatch(pattern, following)) for word, following in zip(arguments, [*arguments[1:], ""]))
def unlimited_container(words: list[str]) -> bool: