mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-05-01 11:41:41 +00:00
fix: enable check to all inputs
This commit is contained in:
@@ -151,16 +151,14 @@ class ADetailerArgs(BaseModel, extra=Extra.forbid):
|
|||||||
|
|
||||||
|
|
||||||
class EnableChecker(BaseModel):
|
class EnableChecker(BaseModel):
|
||||||
a0: Union[bool, dict]
|
enable: bool
|
||||||
a1: Any
|
arg_list: list[dict[str, Any]]
|
||||||
|
|
||||||
def is_enabled(self) -> bool:
|
def is_enabled(self) -> bool:
|
||||||
ad_model = ALL_ARGS[0].attr
|
ad_model = ALL_ARGS[0].attr
|
||||||
if isinstance(self.a0, dict):
|
if not self.enable:
|
||||||
return self.a0.get(ad_model, "None") != "None"
|
|
||||||
if not isinstance(self.a1, dict):
|
|
||||||
return False
|
return False
|
||||||
return self.a0 and self.a1.get(ad_model, "None") != "None"
|
return any(arg.get(ad_model, "None") != "None" for arg in self.arg_list)
|
||||||
|
|
||||||
|
|
||||||
_all_args = [
|
_all_args = [
|
||||||
|
|||||||
@@ -148,15 +148,15 @@ class AfterDetailerScript(scripts.Script):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def is_ad_enabled(self, *args_) -> bool:
|
def is_ad_enabled(self, *args_) -> bool:
|
||||||
if len(args_) == 0 or (len(args_) == 1 and not isinstance(args_[0], dict)):
|
arg_list = [arg for arg in args_ if isinstance(arg, dict)]
|
||||||
|
if not args_ or not arg_list or not isinstance(args_[0], (bool, dict)):
|
||||||
message = f"""
|
message = f"""
|
||||||
[-] ADetailer: Not enough arguments passed to ADetailer.
|
[-] ADetailer: Invalid arguments passed to ADetailer.
|
||||||
input: {args_!r}
|
input: {args_!r}
|
||||||
"""
|
"""
|
||||||
raise ValueError(dedent(message))
|
raise ValueError(dedent(message))
|
||||||
a0 = args_[0]
|
enable = args_[0] if isinstance(args_[0], bool) else True
|
||||||
a1 = args_[1] if len(args_) > 1 else None
|
checker = EnableChecker(enable=enable, arg_list=arg_list)
|
||||||
checker = EnableChecker(a0=a0, a1=a1)
|
|
||||||
return checker.is_enabled()
|
return checker.is_enabled()
|
||||||
|
|
||||||
def get_args(self, p, *args_) -> list[ADetailerArgs]:
|
def get_args(self, p, *args_) -> list[ADetailerArgs]:
|
||||||
|
|||||||
Reference in New Issue
Block a user