Support the action property
This commit is contained in:
parent
9c6b8971b6
commit
f32ee5a1e3
1 changed files with 18 additions and 7 deletions
|
|
@ -112,7 +112,7 @@ DEFAULT_CONFIG.add(
|
||||||
|
|
||||||
DEFAULT_CONFIG.add(
|
DEFAULT_CONFIG.add(
|
||||||
"action_dir",
|
"action_dir",
|
||||||
"The directory containing the action scripts",
|
"The directory to copy the action scripts to",
|
||||||
value="actions")
|
value="actions")
|
||||||
|
|
||||||
DEFAULT_CONFIG.add(
|
DEFAULT_CONFIG.add(
|
||||||
|
|
@ -140,6 +140,8 @@ DEFAULT_CONFIG.add(
|
||||||
"Determines the delimiters for in-line expressions",
|
"Determines the delimiters for in-line expressions",
|
||||||
value=("{{", "}}"))
|
value=("{{", "}}"))
|
||||||
|
|
||||||
|
# Compile-time info
|
||||||
|
|
||||||
DEFAULT_CONFIG.add(
|
DEFAULT_CONFIG.add(
|
||||||
"filename",
|
"filename",
|
||||||
"Name of the file currently being compiled, as a string. Set during compilation",
|
"Name of the file currently being compiled, as a string. Set during compilation",
|
||||||
|
|
@ -285,20 +287,29 @@ class Config:
|
||||||
@property
|
@property
|
||||||
def targets(self) -> List[Path]:
|
def targets(self) -> List[Path]:
|
||||||
name = "targets"
|
name = "targets"
|
||||||
target = self._get(name)
|
targets = self._get(name)
|
||||||
is_path = self._is_pathy(target)
|
|
||||||
is_list_of_paths = (isinstance(target, list) and
|
|
||||||
all(self._is_pathy(elem) for elem in target))
|
|
||||||
|
|
||||||
|
# Check whether targets argument has the correct format
|
||||||
|
is_path = self._is_pathy(targets)
|
||||||
|
is_list_of_paths = (isinstance(targets, list) and
|
||||||
|
all(self._is_pathy(elem) for elem in targets))
|
||||||
if not is_path and not is_list_of_paths:
|
if not is_path and not is_list_of_paths:
|
||||||
raise ConfigurationException(
|
raise ConfigurationException(
|
||||||
style_error("Expected variable ") + style_var(name) +
|
style_error("Expected variable ") + style_var(name) +
|
||||||
style_error(" to be either a path or a list of paths"))
|
style_error(" to be either a path or a list of paths"))
|
||||||
|
|
||||||
|
paths: List[Path]
|
||||||
if is_path:
|
if is_path:
|
||||||
return [self._interpret_path(target)]
|
paths = [self._interpret_path(targets)]
|
||||||
else:
|
else:
|
||||||
return [self._interpret_path(elem) for elem in target]
|
paths = [self._interpret_path(elem) for elem in targets]
|
||||||
|
|
||||||
|
# If this is an action, just treat it like yet another target in a very
|
||||||
|
# specific location
|
||||||
|
if self.action is not None:
|
||||||
|
paths.append(self.action_dir / self.action)
|
||||||
|
|
||||||
|
return paths
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action(self) -> Optional[str]:
|
def action(self) -> Optional[str]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue