Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_focus_pane_index(session):
yaml_config = loadfixture('workspacebuilder/focus_and_pane.yaml')
sconfig = kaptan.Kaptan(handler='yaml')
sconfig = sconfig.import_config(yaml_config).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
builder.build(session=session)
assert session.attached_window.name == 'focused window'
pane_base_index = int(
session.attached_window.show_window_option('pane-base-index', g=True)
)
if not pane_base_index:
pane_base_index = 0
else:
pane_base_index = int(pane_base_index)
def test_before_load_throw_error_if_retcode_error(server):
config_script_fails = loadfixture("workspacebuilder/config_script_fails.yaml")
sconfig = kaptan.Kaptan(handler='yaml')
yaml = config_script_fails.format(
fixtures_dir=fixtures_dir,
script_failed=os.path.join(fixtures_dir, 'script_failed.sh'),
)
sconfig = sconfig.import_config(yaml).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)
builder = WorkspaceBuilder(sconf=sconfig)
with temp_session(server) as sess:
session_name = sess.name
with pytest.raises(exc.BeforeLoadScriptError):
builder.build(session=sess)
result = server.has_session(session_name)
assert not result, "Kills session if before_script exits with errcode"
def test_config_expand2():
"""Expand shell commands from string to list."""
unexpanded_dict = load_yaml(fixtures.expand2.unexpanded_yaml)
expanded_dict = load_yaml(fixtures.expand2.expanded_yaml)
assert config.expand(unexpanded_dict) == expanded_dict
def test_config_to_dict(tmuxinator_yaml, tmuxinator_dict, tmuxp_dict):
configparser = kaptan.Kaptan(handler='yaml')
test_config = configparser.import_config(tmuxinator_yaml)
yaml_to_dict = test_config.get()
assert yaml_to_dict == tmuxinator_dict
assert config.import_tmuxinator(tmuxinator_dict) == tmuxp_dict
config.validate_schema(config.import_tmuxinator(tmuxinator_dict))
def scan_config_argument(ctx, param, value, config_dir=None):
"""Validate / translate config name/path values for click config arg.
Wrapper on top of :func:`cli.scan_config`."""
if callable(config_dir):
config_dir = config_dir()
if not config:
click.echo("Enter at least one CONFIG")
click.echo(ctx.get_help(), color=ctx.color)
ctx.exit()
if isinstance(value, string_types):
value = scan_config(value, config_dir=config_dir)
elif isinstance(value, tuple):
value = tuple([scan_config(v, config_dir=config_dir) for v in value])
return value
References
----------
.. [1] cmd-switch-client.c hook. GitHub repo for tmux.
https://github.com/tmux/tmux/blob/2.6/cmd-switch-client.c#L132.
Accessed April 8th, 2018.
"""
# get the canonical path, eliminating any symlinks
config_file = os.path.realpath(config_file)
# kaptan allows us to open a yaml or json file as a dict
sconfig = kaptan.Kaptan()
sconfig = sconfig.import_config(config_file).get()
# shapes configurations relative to config / profile file location
sconfig = config.expand(sconfig, os.path.dirname(config_file))
# propagate config inheritance (e.g. session -> window, window -> pane)
sconfig = config.trickle(sconfig)
t = Server( # create tmux server object
socket_name=socket_name, socket_path=socket_path, colors=colors
)
which('tmux') # raise exception if tmux not found
try: # load WorkspaceBuilder object for tmuxp config / tmux server
builder = WorkspaceBuilder(sconf=sconfig, server=t)
except exc.EmptyConfigException:
click.echo('%s is empty or parsed no config data' % config_file, err=True)
return
session_name = sconfig['session_name']
# if the session already exists, prompt the user to attach. tmuxp doesn't