Skip to content

Commit 1b80c57

Browse files
committed
refactor: tmuxp_config -> tmuxp_workspace
1 parent a5ab588 commit 1b80c57

File tree

3 files changed

+88
-84
lines changed

3 files changed

+88
-84
lines changed

src/tmuxp/config.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -428,56 +428,60 @@ def import_tmuxinator(workspace_dict):
428428
dict
429429
"""
430430

431-
tmuxp_config = {}
431+
tmuxp_workspace = {}
432432

433433
if "project_name" in workspace_dict:
434-
tmuxp_config["session_name"] = workspace_dict.pop("project_name")
434+
tmuxp_workspace["session_name"] = workspace_dict.pop("project_name")
435435
elif "name" in workspace_dict:
436-
tmuxp_config["session_name"] = workspace_dict.pop("name")
436+
tmuxp_workspace["session_name"] = workspace_dict.pop("name")
437437
else:
438-
tmuxp_config["session_name"] = None
438+
tmuxp_workspace["session_name"] = None
439439

440440
if "project_root" in workspace_dict:
441-
tmuxp_config["start_directory"] = workspace_dict.pop("project_root")
441+
tmuxp_workspace["start_directory"] = workspace_dict.pop("project_root")
442442
elif "root" in workspace_dict:
443-
tmuxp_config["start_directory"] = workspace_dict.pop("root")
443+
tmuxp_workspace["start_directory"] = workspace_dict.pop("root")
444444

445445
if "cli_args" in workspace_dict:
446-
tmuxp_config["config"] = workspace_dict["cli_args"]
446+
tmuxp_workspace["config"] = workspace_dict["cli_args"]
447447

448-
if "-f" in tmuxp_config["config"]:
449-
tmuxp_config["config"] = tmuxp_config["config"].replace("-f", "").strip()
448+
if "-f" in tmuxp_workspace["config"]:
449+
tmuxp_workspace["config"] = (
450+
tmuxp_workspace["config"].replace("-f", "").strip()
451+
)
450452
elif "tmux_options" in workspace_dict:
451-
tmuxp_config["config"] = workspace_dict["tmux_options"]
453+
tmuxp_workspace["config"] = workspace_dict["tmux_options"]
452454

453-
if "-f" in tmuxp_config["config"]:
454-
tmuxp_config["config"] = tmuxp_config["config"].replace("-f", "").strip()
455+
if "-f" in tmuxp_workspace["config"]:
456+
tmuxp_workspace["config"] = (
457+
tmuxp_workspace["config"].replace("-f", "").strip()
458+
)
455459

456460
if "socket_name" in workspace_dict:
457-
tmuxp_config["socket_name"] = workspace_dict["socket_name"]
461+
tmuxp_workspace["socket_name"] = workspace_dict["socket_name"]
458462

459-
tmuxp_config["windows"] = []
463+
tmuxp_workspace["windows"] = []
460464

461465
if "tabs" in workspace_dict:
462466
workspace_dict["windows"] = workspace_dict.pop("tabs")
463467

464468
if "pre" in workspace_dict and "pre_window" in workspace_dict:
465-
tmuxp_config["shell_command"] = workspace_dict["pre"]
469+
tmuxp_workspace["shell_command"] = workspace_dict["pre"]
466470

467471
if isinstance(workspace_dict["pre"], str):
468-
tmuxp_config["shell_command_before"] = [workspace_dict["pre_window"]]
472+
tmuxp_workspace["shell_command_before"] = [workspace_dict["pre_window"]]
469473
else:
470-
tmuxp_config["shell_command_before"] = workspace_dict["pre_window"]
474+
tmuxp_workspace["shell_command_before"] = workspace_dict["pre_window"]
471475
elif "pre" in workspace_dict:
472476
if isinstance(workspace_dict["pre"], str):
473-
tmuxp_config["shell_command_before"] = [workspace_dict["pre"]]
477+
tmuxp_workspace["shell_command_before"] = [workspace_dict["pre"]]
474478
else:
475-
tmuxp_config["shell_command_before"] = workspace_dict["pre"]
479+
tmuxp_workspace["shell_command_before"] = workspace_dict["pre"]
476480

477481
if "rbenv" in workspace_dict:
478-
if "shell_command_before" not in tmuxp_config:
479-
tmuxp_config["shell_command_before"] = []
480-
tmuxp_config["shell_command_before"].append(
482+
if "shell_command_before" not in tmuxp_workspace:
483+
tmuxp_workspace["shell_command_before"] = []
484+
tmuxp_workspace["shell_command_before"].append(
481485
"rbenv shell %s" % workspace_dict["rbenv"]
482486
)
483487

@@ -487,11 +491,11 @@ def import_tmuxinator(workspace_dict):
487491

488492
if isinstance(v, str) or v is None:
489493
window_dict["panes"] = [v]
490-
tmuxp_config["windows"].append(window_dict)
494+
tmuxp_workspace["windows"].append(window_dict)
491495
continue
492496
elif isinstance(v, list):
493497
window_dict["panes"] = v
494-
tmuxp_config["windows"].append(window_dict)
498+
tmuxp_workspace["windows"].append(window_dict)
495499
continue
496500

497501
if "pre" in v:
@@ -503,8 +507,8 @@ def import_tmuxinator(workspace_dict):
503507

504508
if "layout" in v:
505509
window_dict["layout"] = v["layout"]
506-
tmuxp_config["windows"].append(window_dict)
507-
return tmuxp_config
510+
tmuxp_workspace["windows"].append(window_dict)
511+
return tmuxp_workspace
508512

509513

510514
def import_teamocil(workspace_dict):
@@ -529,20 +533,20 @@ def import_teamocil(workspace_dict):
529533
- cmd_separator
530534
"""
531535

532-
tmuxp_config = {}
536+
tmuxp_workspace = {}
533537

534538
if "session" in workspace_dict:
535539
workspace_dict = workspace_dict["session"]
536540

537541
if "name" in workspace_dict:
538-
tmuxp_config["session_name"] = workspace_dict["name"]
542+
tmuxp_workspace["session_name"] = workspace_dict["name"]
539543
else:
540-
tmuxp_config["session_name"] = None
544+
tmuxp_workspace["session_name"] = None
541545

542546
if "root" in workspace_dict:
543-
tmuxp_config["start_directory"] = workspace_dict.pop("root")
547+
tmuxp_workspace["start_directory"] = workspace_dict.pop("root")
544548

545-
tmuxp_config["windows"] = []
549+
tmuxp_workspace["windows"] = []
546550

547551
for w in workspace_dict["windows"]:
548552
window_dict = {"window_name": w["name"]}
@@ -575,6 +579,6 @@ def import_teamocil(workspace_dict):
575579

576580
if "layout" in w:
577581
window_dict["layout"] = w["layout"]
578-
tmuxp_config["windows"].append(window_dict)
582+
tmuxp_workspace["windows"].append(window_dict)
579583

580-
return tmuxp_config
584+
return tmuxp_workspace

tests/fixtures/config/expand1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
before_config = {
3+
before_workspace = {
44
"session_name": "sample workspace",
55
"start_directory": "~",
66
"windows": [
@@ -30,7 +30,7 @@
3030
}
3131

3232

33-
def after_config():
33+
def after_workspace():
3434
return {
3535
"session_name": "sample workspace",
3636
"start_directory": os.path.expanduser("~"),

0 commit comments

Comments
 (0)