@@ -38,21 +38,31 @@ def optional_windows_and_pane(
3838 if isinstance (if_cond , (str , bool )):
3939 # treat this as shell variable
4040 if_cond = {"shell_var" : if_cond }
41- if not isinstance (if_cond , dict ) or not any (predicate in if_cond for predicate in ("python" , "shell" , "shell_var" )):
42- raise ValueError (f"if conditions does not contains valid expression: { if_cond } " )
41+ if not isinstance (if_cond , dict ) or not any (
42+ predicate in if_cond for predicate in ("python" , "shell" , "shell_var" )
43+ ):
44+ msg = f"if conditions does not contains valid expression: { if_cond } "
45+ raise ValueError (msg )
4346 if "shell_var" in if_cond :
44- if expandshell (str (if_cond ["shell_var" ])).lower () not in ("y" , "yes" , "1" , "on" , "true" , "t" ):
47+ if expandshell (str (if_cond ["shell_var" ])).lower () not in {
48+ "y" ,
49+ "yes" ,
50+ "1" ,
51+ "on" ,
52+ "true" ,
53+ "t" ,
54+ }:
4555 return False
4656 if "shell" in if_cond :
47- if subprocess .run (if_cond ["shell" ], shell = True ).returncode != 0 :
57+ if subprocess .run (if_cond ["shell" ], shell = True , check = False ).returncode != 0 :
4858 return False
4959 if "python" in if_cond :
5060 # assign the result of the last statement from the python snippet
5161 py_statements = if_cond ["python" ].split (";" )
5262 py_statements [- 1 ] = f"ret={ py_statements [- 1 ]} "
5363 locals = {}
5464 exec (";" .join (py_statements ), {}, locals )
55- if not locals [' ret' ]:
65+ if not locals [" ret" ]:
5666 return False
5767 return True
5868
@@ -224,7 +234,7 @@ def expand(
224234 if "windows" in workspace_dict :
225235 window_dicts = workspace_dict ["windows" ]
226236 window_dicts = filter (optional_windows_and_pane , window_dicts )
227- window_dicts = map ( lambda x : expand (x , parent = workspace_dict ), window_dicts )
237+ window_dicts = ( expand (x , parent = workspace_dict ) for x in window_dicts )
228238 # remove windows that has no panels (e.g. due to if conditions)
229239 window_dicts = filter (lambda x : len (x ["panes" ]), window_dicts )
230240 workspace_dict ["windows" ] = list (window_dicts )
@@ -235,7 +245,7 @@ def expand(
235245 pane_dicts [pane_idx ] = {}
236246 pane_dicts [pane_idx ].update (expand_cmd (pane_dict ))
237247 pane_dicts = filter (optional_windows_and_pane , pane_dicts )
238- pane_dicts = map ( lambda x : expand (x , parent = workspace_dict ), pane_dicts )
248+ pane_dicts = ( expand (x , parent = workspace_dict ) for x in pane_dicts )
239249 workspace_dict ["panes" ] = list (pane_dicts )
240250
241251 return workspace_dict
0 commit comments