Skip to content

Commit 1098968

Browse files
committed
refactor!: Rename config to loader
1 parent 26f5b65 commit 1098968

File tree

6 files changed

+68
-68
lines changed

6 files changed

+68
-68
lines changed

docs/api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ If you need an internal API stabilized please [file an issue](https://github.com
9090
### Processing
9191

9292
```{eval-rst}
93-
.. automethod:: tmuxp.workspace.config.expandshell
93+
.. automethod:: tmuxp.workspace.loader.expandshell
9494
```
9595

9696
```{eval-rst}
97-
.. automethod:: tmuxp.workspace.config.expand
97+
.. automethod:: tmuxp.workspace.loader.expand
9898
```
9999

100100
```{eval-rst}
101-
.. automethod:: tmuxp.workspace.config.trickle
101+
.. automethod:: tmuxp.workspace.loader.trickle
102102
```
103103

104104
## Workspace importers

src/tmuxp/cli/load.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from tmuxp.types import StrPath
2020

2121
from .. import config_reader, exc, log, util
22-
from ..workspace import config
22+
from ..workspace import loader
2323
from ..workspace.builder import WorkspaceBuilder
2424
from ..workspace.finders import find_workspace_file, get_workspace_dir, in_dir
2525
from .utils import prompt_choices, prompt_yes_no, style, tmuxp_echo
@@ -290,12 +290,12 @@ def load_workspace(
290290
-----
291291
292292
tmuxp will check and load a workspace file. The file will use ConfigReader
293-
to load a JSON/YAML into a :py:obj:`dict`. Then :func:`config.expand` and
294-
:func:`config.trickle` will be used to expand any shorthands, template
293+
to load a JSON/YAML into a :py:obj:`dict`. Then :func:`loader.expand` and
294+
:func:`loader.trickle` will be used to expand any shorthands, template
295295
variables, or file paths relative to where the config/script is executed
296296
from.
297297
298-
:func:`config.expand` accepts the directory of the config file, so the
298+
:func:`loader.expand` accepts the directory of the config file, so the
299299
user's workspace can resolve absolute paths relative to where the
300300
workspace file is. In otherwords, if a workspace file at */var/moo/hi.yaml*
301301
has *./* in its workspaces, we want to be sure any file path with *./* is
@@ -368,7 +368,7 @@ def load_workspace(
368368
raw_workspace = config_reader.ConfigReader._from_file(workspace_file) or {}
369369

370370
# shapes workspaces relative to config / profile file location
371-
expanded_workspace = config.expand(
371+
expanded_workspace = loader.expand(
372372
raw_workspace, cwd=os.path.dirname(workspace_file)
373373
)
374374

@@ -377,7 +377,7 @@ def load_workspace(
377377
expanded_workspace["session_name"] = new_session_name
378378

379379
# propagate workspace inheritance (e.g. session -> window, window -> pane)
380-
expanded_workspace = config.trickle(expanded_workspace)
380+
expanded_workspace = loader.trickle(expanded_workspace)
381381

382382
t = Server( # create tmux server object
383383
socket_name=socket_name,
File renamed without changes.

tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from tmuxp.cli.utils import tmuxp_echo
2727
from tmuxp.config_reader import ConfigReader
28-
from tmuxp.workspace import config
28+
from tmuxp.workspace import loader
2929
from tmuxp.workspace.builder import WorkspaceBuilder
3030
from tmuxp.workspace.finders import find_workspace_file
3131

@@ -1130,7 +1130,7 @@ def test_load_plugins(monkeypatch_plugin_test_packages: None) -> None:
11301130
plugins_config = test_utils.read_workspace_file("workspace/builder/plugin_bwb.yaml")
11311131

11321132
sconfig = ConfigReader._load(format="yaml", content=plugins_config)
1133-
sconfig = config.expand(sconfig)
1133+
sconfig = loader.expand(sconfig)
11341134

11351135
plugins = load_plugins(sconfig)
11361136

@@ -1236,7 +1236,7 @@ def test_reattach_plugins(
12361236
config_plugins = test_utils.read_workspace_file("workspace/builder/plugin_r.yaml")
12371237

12381238
sconfig = ConfigReader._load(format="yaml", content=config_plugins)
1239-
sconfig = config.expand(sconfig)
1239+
sconfig = loader.expand(sconfig)
12401240

12411241
# open it detached
12421242
builder = WorkspaceBuilder(

tests/workspace/test_builder.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from tmuxp import exc
1515
from tmuxp.cli.load import load_plugins
1616
from tmuxp.config_reader import ConfigReader
17-
from tmuxp.workspace import config
17+
from tmuxp.workspace import loader
1818
from tmuxp.workspace.builder import WorkspaceBuilder
1919

2020
from ..constants import EXAMPLE_PATH, FIXTURE_PATH
@@ -70,8 +70,8 @@ def test_focus_pane_index(session):
7070
workspace = ConfigReader._from_file(
7171
test_utils.get_workspace_file("workspace/builder/focus_and_pane.yaml")
7272
)
73-
workspace = config.expand(workspace)
74-
workspace = config.trickle(workspace)
73+
workspace = loader.expand(workspace)
74+
workspace = loader.trickle(workspace)
7575

7676
builder = WorkspaceBuilder(sconf=workspace)
7777

@@ -144,8 +144,8 @@ def test_suppress_history(session):
144144
workspace = ConfigReader._from_file(
145145
test_utils.get_workspace_file("workspace/builder/suppress_history.yaml")
146146
)
147-
workspace = config.expand(workspace)
148-
workspace = config.trickle(workspace)
147+
workspace = loader.expand(workspace)
148+
workspace = loader.trickle(workspace)
149149

150150
builder = WorkspaceBuilder(sconf=workspace)
151151
builder.build(session=session)
@@ -198,7 +198,7 @@ def test_session_options(session):
198198
workspace = ConfigReader._from_file(
199199
test_utils.get_workspace_file("workspace/builder/session_options.yaml")
200200
)
201-
workspace = config.expand(workspace)
201+
workspace = loader.expand(workspace)
202202

203203
builder = WorkspaceBuilder(sconf=workspace)
204204
builder.build(session=session)
@@ -211,7 +211,7 @@ def test_global_options(session):
211211
workspace = ConfigReader._from_file(
212212
test_utils.get_workspace_file("workspace/builder/global_options.yaml")
213213
)
214-
workspace = config.expand(workspace)
214+
workspace = loader.expand(workspace)
215215

216216
builder = WorkspaceBuilder(sconf=workspace)
217217
builder.build(session=session)
@@ -231,7 +231,7 @@ def test_global_session_env_options(session, monkeypatch):
231231
workspace = ConfigReader._from_file(
232232
test_utils.get_workspace_file("workspace/builder/env_var_options.yaml")
233233
)
234-
workspace = config.expand(workspace)
234+
workspace = loader.expand(workspace)
235235

236236
builder = WorkspaceBuilder(sconf=workspace)
237237
builder.build(session=session)
@@ -247,7 +247,7 @@ def test_window_options(session):
247247
workspace = ConfigReader._from_file(
248248
test_utils.get_workspace_file("workspace/builder/window_options.yaml")
249249
)
250-
workspace = config.expand(workspace)
250+
workspace = loader.expand(workspace)
251251

252252
if has_gte_version("2.3"):
253253
workspace["windows"][0]["options"]["pane-border-format"] = " #P "
@@ -276,7 +276,7 @@ def test_window_options_after(session):
276276
workspace = ConfigReader._from_file(
277277
test_utils.get_workspace_file("workspace/builder/window_options_after.yaml")
278278
)
279-
workspace = config.expand(workspace)
279+
workspace = loader.expand(workspace)
280280

281281
builder = WorkspaceBuilder(sconf=workspace)
282282
builder.build(session=session)
@@ -314,7 +314,7 @@ def test_window_shell(session):
314314
workspace = ConfigReader._from_file(
315315
test_utils.get_workspace_file("workspace/builder/window_shell.yaml")
316316
)
317-
workspace = config.expand(workspace)
317+
workspace = loader.expand(workspace)
318318

319319
builder = WorkspaceBuilder(sconf=workspace)
320320

@@ -335,7 +335,7 @@ def test_environment_variables(session):
335335
workspace = ConfigReader._from_file(
336336
test_utils.get_workspace_file("workspace/builder/environment_vars.yaml")
337337
)
338-
workspace = config.expand(workspace)
338+
workspace = loader.expand(workspace)
339339

340340
builder = WorkspaceBuilder(sconf=workspace)
341341
builder.build(session)
@@ -404,7 +404,7 @@ def test_blank_pane_count(session):
404404
yaml_workspace_file = EXAMPLE_PATH / "blank-panes.yaml"
405405
test_config = ConfigReader._from_file(yaml_workspace_file)
406406

407-
test_config = config.expand(test_config)
407+
test_config = loader.expand(test_config)
408408
builder = WorkspaceBuilder(sconf=test_config)
409409
builder.build(session=session)
410410

@@ -433,8 +433,8 @@ def test_start_directory(session, tmp_path: pathlib.Path):
433433
test_config = yaml_workspace.format(TEST_DIR=test_dir)
434434

435435
workspace = ConfigReader._load(format="yaml", content=test_config)
436-
workspace = config.expand(workspace)
437-
workspace = config.trickle(workspace)
436+
workspace = loader.expand(workspace)
437+
workspace = loader.trickle(workspace)
438438

439439
builder = WorkspaceBuilder(sconf=workspace)
440440
builder.build(session=session)
@@ -479,9 +479,9 @@ def test_start_directory_relative(session, tmp_path: pathlib.Path):
479479
workspace = ConfigReader._load(format="yaml", content=test_config)
480480
# the second argument of os.getcwd() mimics the behavior
481481
# the CLI loader will do, but it passes in the workspace file's location.
482-
workspace = config.expand(workspace, config_dir)
482+
workspace = loader.expand(workspace, config_dir)
483483

484-
workspace = config.trickle(workspace)
484+
workspace = loader.trickle(workspace)
485485

486486
assert os.path.exists(config_dir)
487487
assert os.path.exists(test_dir)
@@ -513,8 +513,8 @@ def test_start_directory_sets_session_path(server):
513513
"workspace/builder/start_directory_session_path.yaml"
514514
)
515515
)
516-
workspace = config.expand(workspace)
517-
workspace = config.trickle(workspace)
516+
workspace = loader.expand(workspace)
517+
workspace = loader.trickle(workspace)
518518

519519
builder = WorkspaceBuilder(sconf=workspace, server=server)
520520
builder.build()
@@ -544,8 +544,8 @@ def test_pane_order(session):
544544
]
545545

546546
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
547-
workspace = config.expand(workspace)
548-
workspace = config.trickle(workspace)
547+
workspace = loader.expand(workspace)
548+
workspace = loader.trickle(workspace)
549549

550550
builder = WorkspaceBuilder(sconf=workspace)
551551

@@ -586,8 +586,8 @@ def test_window_index(session):
586586
workspace = ConfigReader._from_file(
587587
test_utils.get_workspace_file("workspace/builder/window_index.yaml")
588588
)
589-
workspace = config.expand(workspace)
590-
workspace = config.trickle(workspace)
589+
workspace = loader.expand(workspace)
590+
workspace = loader.trickle(workspace)
591591

592592
builder = WorkspaceBuilder(sconf=workspace)
593593

@@ -605,8 +605,8 @@ def test_before_load_throw_error_if_retcode_error(server):
605605
)
606606

607607
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
608-
workspace = config.expand(workspace)
609-
workspace = config.trickle(workspace)
608+
workspace = loader.expand(workspace)
609+
workspace = loader.trickle(workspace)
610610

611611
builder = WorkspaceBuilder(sconf=workspace)
612612

@@ -628,8 +628,8 @@ def test_before_load_throw_error_if_file_not_exists(server):
628628
script_not_exists=FIXTURE_PATH / "script_not_exists.sh",
629629
)
630630
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
631-
workspace = config.expand(workspace)
632-
workspace = config.trickle(workspace)
631+
workspace = loader.expand(workspace)
632+
workspace = loader.trickle(workspace)
633633

634634
builder = WorkspaceBuilder(sconf=workspace)
635635

@@ -653,8 +653,8 @@ def test_before_load_true_if_test_passes(server):
653653

654654
yaml_workspace = config_script_completes.format(script_complete=script_complete_sh)
655655
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
656-
workspace = config.expand(workspace)
657-
workspace = config.trickle(workspace)
656+
workspace = loader.expand(workspace)
657+
workspace = loader.trickle(workspace)
658658

659659
builder = WorkspaceBuilder(sconf=workspace)
660660

@@ -672,8 +672,8 @@ def test_before_load_true_if_test_passes_with_args(server):
672672
yaml_workspace = config_script_completes.format(script_complete=script_complete_sh)
673673

674674
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
675-
workspace = config.expand(workspace)
676-
workspace = config.trickle(workspace)
675+
workspace = loader.expand(workspace)
676+
workspace = loader.trickle(workspace)
677677

678678
builder = WorkspaceBuilder(sconf=workspace)
679679

@@ -687,7 +687,7 @@ def test_plugin_system_before_workspace_builder(
687687
workspace = ConfigReader._from_file(
688688
path=test_utils.get_workspace_file("workspace/builder/plugin_bwb.yaml")
689689
)
690-
workspace = config.expand(workspace)
690+
workspace = loader.expand(workspace)
691691

692692
builder = WorkspaceBuilder(sconf=workspace, plugins=load_plugins(workspace))
693693
assert len(builder.plugins) > 0
@@ -702,7 +702,7 @@ def test_plugin_system_on_window_create(monkeypatch_plugin_test_packages, sessio
702702
workspace = ConfigReader._from_file(
703703
path=test_utils.get_workspace_file("workspace/builder/plugin_owc.yaml")
704704
)
705-
workspace = config.expand(workspace)
705+
workspace = loader.expand(workspace)
706706

707707
builder = WorkspaceBuilder(sconf=workspace, plugins=load_plugins(workspace))
708708
assert len(builder.plugins) > 0
@@ -717,7 +717,7 @@ def test_plugin_system_after_window_finished(monkeypatch_plugin_test_packages, s
717717
workspace = ConfigReader._from_file(
718718
path=test_utils.get_workspace_file("workspace/builder/plugin_awf.yaml")
719719
)
720-
workspace = config.expand(workspace)
720+
workspace = loader.expand(workspace)
721721

722722
builder = WorkspaceBuilder(sconf=workspace, plugins=load_plugins(workspace))
723723
assert len(builder.plugins) > 0
@@ -734,7 +734,7 @@ def test_plugin_system_on_window_create_multiple_windows(session):
734734
"workspace/builder/plugin_owc_multiple_windows.yaml"
735735
)
736736
)
737-
workspace = config.expand(workspace)
737+
workspace = loader.expand(workspace)
738738

739739
builder = WorkspaceBuilder(sconf=workspace, plugins=load_plugins(workspace))
740740
assert len(builder.plugins) > 0
@@ -754,7 +754,7 @@ def test_plugin_system_after_window_finished_multiple_windows(
754754
"workspace/builder/plugin_awf_multiple_windows.yaml"
755755
)
756756
)
757-
workspace = config.expand(workspace)
757+
workspace = loader.expand(workspace)
758758

759759
builder = WorkspaceBuilder(sconf=workspace, plugins=load_plugins(workspace))
760760
assert len(builder.plugins) > 0
@@ -772,7 +772,7 @@ def test_plugin_system_multiple_plugins(monkeypatch_plugin_test_packages, sessio
772772
"workspace/builder/plugin_multiple_plugins.yaml"
773773
)
774774
)
775-
workspace = config.expand(workspace)
775+
workspace = loader.expand(workspace)
776776

777777
builder = WorkspaceBuilder(sconf=workspace, plugins=load_plugins(workspace))
778778
assert len(builder.plugins) > 0
@@ -1005,8 +1005,8 @@ def test_load_workspace_enter(
10051005
yaml_workspace = tmp_path / "simple.yaml"
10061006
yaml_workspace.write_text(yaml, encoding="utf-8")
10071007
workspace = ConfigReader._from_file(yaml_workspace)
1008-
workspace = config.expand(workspace)
1009-
workspace = config.trickle(workspace)
1008+
workspace = loader.expand(workspace)
1009+
workspace = loader.trickle(workspace)
10101010
builder = WorkspaceBuilder(sconf=workspace, server=server)
10111011
builder.build()
10121012

@@ -1125,8 +1125,8 @@ def test_load_workspace_sleep(
11251125
yaml_workspace = tmp_path / "simple.yaml"
11261126
yaml_workspace.write_text(yaml, encoding="utf-8")
11271127
workspace = ConfigReader._from_file(yaml_workspace)
1128-
workspace = config.expand(workspace)
1129-
workspace = config.trickle(workspace)
1128+
workspace = loader.expand(workspace)
1129+
workspace = loader.trickle(workspace)
11301130
builder = WorkspaceBuilder(sconf=workspace, server=server)
11311131

11321132
t = time.process_time()
@@ -1151,8 +1151,8 @@ def test_first_pane_start_directory(session, tmp_path: pathlib.Path):
11511151
)
11521152

11531153
workspace = ConfigReader._from_file(yaml_workspace)
1154-
workspace = config.expand(workspace)
1155-
workspace = config.trickle(workspace)
1154+
workspace = loader.expand(workspace)
1155+
workspace = loader.trickle(workspace)
11561156

11571157
builder = WorkspaceBuilder(sconf=workspace)
11581158
builder.build(session=session)
@@ -1268,8 +1268,8 @@ def test_issue_800_default_size_many_windows(
12681268
)
12691269

12701270
workspace = ConfigReader._from_file(yaml_workspace)
1271-
workspace = config.expand(workspace)
1272-
workspace = config.trickle(workspace)
1271+
workspace = loader.expand(workspace)
1272+
workspace = loader.trickle(workspace)
12731273

12741274
if isinstance(confoverrides, dict):
12751275
for k, v in confoverrides.items():

0 commit comments

Comments
 (0)