From 094bb5e0cd5311eb5985ac416c140d2e6f65241c Mon Sep 17 00:00:00 2001 From: jaimergp Date: Mon, 11 Nov 2024 12:49:35 +0100 Subject: [PATCH] use inline conditionals to clean some lines up --- constructor/header.sh | 18 +++-------------- constructor/nsis/main.nsi.tmpl | 36 ++++++---------------------------- 2 files changed, 9 insertions(+), 45 deletions(-) diff --git a/constructor/header.sh b/constructor/header.sh index 035b364b0..a05b7924e 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -78,17 +78,9 @@ THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd) THIS_FILE=$(basename "$0") THIS_PATH="$THIS_DIR/$THIS_FILE" PREFIX="{{ default_prefix }}" -{%- if batch_mode %} -BATCH=1 -{%- else %} -BATCH=0 -{%- endif %} +BATCH={{ 1 if batch_mode else 0 }} FORCE=0 -{%- if keep_pkgs %} -KEEP_PKGS=1 -{%- else %} -KEEP_PKGS=0 -{%- endif %} +KEEP_PKGS={{ 1 if keep_pkgs else 0 }} SKIP_SCRIPTS=0 {%- if enable_shortcuts == "true" %} SKIP_SHORTCUTS=0 @@ -644,11 +636,7 @@ fi if [ "$BATCH" = "0" ]; then {%- if has_conda and initialize_conda %} -{%- if initialize_by_default %} - DEFAULT=yes -{%- else %} - DEFAULT=no -{%- endif %} + DEFAULT={{ 'yes' if initialize_by_default else 'no' }} # Interactive mode. printf "Do you wish to update your shell profile to automatically initialize conda?\\n" diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index 8283fe764..44af0081c 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -269,11 +269,7 @@ FunctionEnd $\n\ /InstallationType=AllUsers [default: JustMe]$\n\ /AddToPath=[0|1] [default: 0]$\n\ -{%- if keep_pkgs %} - /KeepPkgCache=[0|1] [default: 1]$\n\ -{%- else %} - /KeepPkgCache=[0|1] [default: 0]$\n\ -{%- endif %} + /KeepPkgCache=[0|1] [default: {{ 1 if keep_pkgs else 0 }}]$\n\ /RegisterPython=[0|1] [default: AllUsers: 1, JustMe: 0]$\n\ /NoRegistry=[0|1] [default: AllUsers: 0, JustMe: 0]$\n\ /NoScripts=[0|1] [default: 0]$\n\ @@ -701,32 +697,12 @@ Function .onInit {%- endif %} {%- endif %} {%- if register_python %} -{%- if register_python_default %} - StrCpy $Ana_RegisterSystemPython_State ${BST_CHECKED} -{%- else %} - StrCpy $Ana_RegisterSystemPython_State ${BST_UNCHECKED} -{%- endif %} -{%- endif %} -{%- if check_path_length %} - StrCpy $CheckPathLength "1" -{%- else %} - StrCpy $CheckPathLength "0" -{%- endif %} -{%- if keep_pkgs %} - StrCpy $Ana_ClearPkgCache_State ${BST_UNCHECKED} -{%- else %} - StrCpy $Ana_ClearPkgCache_State ${BST_CHECKED} -{%- endif %} -{%- if pre_install_exists %} - StrCpy $Ana_PreInstall_State ${BST_CHECKED} -{%- else %} - StrCpy $Ana_PreInstall_State ${BST_UNCHECKED} -{%- endif %} -{%- if post_install_exists %} - StrCpy $Ana_PostInstall_State ${BST_CHECKED} -{%- else %} - StrCpy $Ana_PostInstall_State ${BST_UNCHECKED} + StrCpy $Ana_RegisterSystemPython_State {{ '${BST_CHECKED}' if register_python_default else '${BST_UNCHECKED}' }} {%- endif %} + StrCpy $CheckPathLength "{{ 1 if check_path_length else 0 }}" + StrCpy $Ana_ClearPkgCache_State {{ '${BST_UNCHECKED}' if keep_pkgs else '${BST_CHECKED}' }} + StrCpy $Ana_PreInstall_State {{ '${BST_CHECKED}' if pre_install_exists else '${BST_UNCHECKED}' }} + StrCpy $Ana_PostInstall_State {{ '${BST_CHECKED}' if post_install_exists else '${BST_UNCHECKED}' }} Call OnInit_Release