lint, another msg
This commit is contained in:
parent
a291d3abb4
commit
4bbe2c7733
3 changed files with 27 additions and 5 deletions
|
|
@ -12,7 +12,8 @@ from ytdl_sub.entries.variables.override_variables import OverrideVariables
|
|||
from ytdl_sub.script.parser import parse
|
||||
from ytdl_sub.script.script import Script
|
||||
from ytdl_sub.script.utils.exceptions import ScriptVariableNotResolved
|
||||
from ytdl_sub.utils.exceptions import InvalidVariableNameException, StringFormattingException
|
||||
from ytdl_sub.utils.exceptions import InvalidVariableNameException
|
||||
from ytdl_sub.utils.exceptions import StringFormattingException
|
||||
from ytdl_sub.utils.exceptions import ValidationException
|
||||
from ytdl_sub.utils.script import ScriptUtils
|
||||
from ytdl_sub.utils.scriptable import Scriptable
|
||||
|
|
@ -171,6 +172,11 @@ class Overrides(DictFormatterValidator, Scriptable):
|
|||
Returns
|
||||
-------
|
||||
The format_string after .format has been called
|
||||
|
||||
Raises
|
||||
------
|
||||
StringFormattingException
|
||||
If the formatter that is trying to be resolved cannot
|
||||
"""
|
||||
script: Script = self.script
|
||||
unresolvable: Set[str] = self.unresolvable
|
||||
|
|
|
|||
|
|
@ -11,11 +11,12 @@ from ytdl_sub.script.types.resolvable import Lambda
|
|||
from ytdl_sub.script.types.resolvable import Resolvable
|
||||
from ytdl_sub.script.types.syntax_tree import SyntaxTree
|
||||
from ytdl_sub.script.types.variable import Variable
|
||||
from ytdl_sub.script.utils.exceptions import UNREACHABLE, ScriptVariableNotResolved
|
||||
from ytdl_sub.script.utils.exceptions import UNREACHABLE
|
||||
from ytdl_sub.script.utils.exceptions import CycleDetected
|
||||
from ytdl_sub.script.utils.exceptions import IncompatibleFunctionArguments
|
||||
from ytdl_sub.script.utils.exceptions import InvalidCustomFunctionArguments
|
||||
from ytdl_sub.script.utils.exceptions import RuntimeException
|
||||
from ytdl_sub.script.utils.exceptions import ScriptVariableNotResolved
|
||||
from ytdl_sub.script.utils.name_validation import validate_variable_name
|
||||
from ytdl_sub.script.utils.type_checking import FunctionSpec
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ from ytdl_sub.entries.script.variable_definitions import Variable
|
|||
from ytdl_sub.entries.script.variable_scripts import UNRESOLVED_VARIABLES
|
||||
from ytdl_sub.entries.script.variable_scripts import VARIABLE_SCRIPTS
|
||||
from ytdl_sub.script.script import Script
|
||||
from ytdl_sub.script.utils.exceptions import RuntimeException
|
||||
from ytdl_sub.utils.exceptions import StringFormattingException
|
||||
from ytdl_sub.utils.script import ScriptUtils
|
||||
|
||||
|
||||
|
|
@ -37,15 +39,28 @@ class Scriptable(ABC):
|
|||
Add new values to the script
|
||||
"""
|
||||
values_as_str: Dict[str, str] = {
|
||||
(key.variable_name if isinstance(key, Variable) else key): val
|
||||
for key, val in values.items()
|
||||
(var.variable_name if isinstance(var, Variable) else var): definition
|
||||
for var, definition in values.items()
|
||||
}
|
||||
|
||||
self.unresolvable -= set(list(values_as_str.keys()))
|
||||
self.script.add(
|
||||
ScriptUtils.add_sanitized_variables(
|
||||
{name: ScriptUtils.to_script(value) for name, value in values_as_str.items()}
|
||||
{
|
||||
name: ScriptUtils.to_script(definition)
|
||||
for name, definition in values_as_str.items()
|
||||
}
|
||||
),
|
||||
unresolvable=self.unresolvable,
|
||||
)
|
||||
self.update_script()
|
||||
|
||||
for name, definition in values_as_str.items():
|
||||
try:
|
||||
_ = self.script.get(variable_name=name)
|
||||
except RuntimeException as exc:
|
||||
raise StringFormattingException(
|
||||
f"Tried to create the variable with name {name} and definition:\n"
|
||||
f"{definition}\n"
|
||||
f"But could not because it has variable dependencies that are not resolved yet"
|
||||
) from exc
|
||||
|
|
|
|||
Loading…
Reference in a new issue