mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-06 12:48:22 +02:00
patch.multiple_safe_eval and patch.safe_eval are now the safe function with a multiple parameter
This commit is contained in:
parent
4c1c8833b1
commit
efd314fb9a
1 changed files with 6 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
|
||||||
from source.mkw.Patch import *
|
from source.mkw.Patch import *
|
||||||
from source.safe_eval import safe_eval
|
from source.safe_eval import safe_eval, multiple_safe_eval
|
||||||
|
|
||||||
|
|
||||||
class Patch:
|
class Patch:
|
||||||
|
@ -16,23 +16,18 @@ class Patch:
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"<{self.__class__.__name__} {self.path}>"
|
return f"<{self.__class__.__name__} {self.path}>"
|
||||||
|
|
||||||
def safe_eval(self, template: str, **env) -> str:
|
def safe_eval(self, template: str, multiple: bool = False, **env) -> str:
|
||||||
"""
|
"""
|
||||||
Safe eval with a patch environment
|
Safe eval with a patch environment
|
||||||
|
:param multiple: should the expression be a multiple safe eval or a single safe eval
|
||||||
:param env: other variable that are allowed in the safe_eval
|
:param env: other variable that are allowed in the safe_eval
|
||||||
:param template: template to evaluate
|
:param template: template to evaluate
|
||||||
:return: the result of the evaluation
|
:return: the result of the evaluation
|
||||||
"""
|
"""
|
||||||
return safe_eval(
|
return (multiple_safe_eval if multiple else safe_eval)(
|
||||||
template,
|
template,
|
||||||
extra_token_map={
|
extra_token_map={"mod_config": "mod_config"} | {key: key for key in env},
|
||||||
"extracted_game": "extracted_game"
|
env={"mod_config": self.mod_config} | env,
|
||||||
} | {
|
|
||||||
key: key for key in env
|
|
||||||
},
|
|
||||||
env={
|
|
||||||
"mod_config": self.mod_config
|
|
||||||
} | env,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def install(self, extracted_game: "ExtractedGame") -> Generator[dict, None, None]:
|
def install(self, extracted_game: "ExtractedGame") -> Generator[dict, None, None]:
|
||||||
|
|
Loading…
Reference in a new issue