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_no_windows():
yaml_config = """
session_name: test session
"""
sconfig = kaptan.Kaptan(handler='yaml')
sconfig = sconfig.import_config(yaml_config).get()
with pytest.raises(exc.ConfigError) as excinfo:
config.validate_schema(sconfig)
assert excinfo.match(r'list of "windows"')
- window_name: editor
panes:
shell_command:
- tail -F /var/log/syslog
start_directory: /var/log
- window_name: logging
automatic-rename: true
panes:
- shell_command:
- htop
"""
sconfig = kaptan.Kaptan(handler='yaml')
sconfig = sconfig.import_config(yaml_config).get()
with pytest.raises(exc.ConfigError) as excinfo:
config.validate_schema(sconfig)
assert excinfo.matches(r'requires "session_name"')
Returns
-------
bool
"""
# verify session_name
if 'session_name' not in sconf:
raise exc.ConfigError('config requires "session_name"')
if 'windows' not in sconf:
raise exc.ConfigError('config requires list of "windows"')
for window in sconf['windows']:
if 'window_name' not in window:
raise exc.ConfigError('config window is missing "window_name"')
return True
Parameters
----------
sconf : dict
session configuration
Returns
-------
bool
"""
# verify session_name
if 'session_name' not in sconf:
raise exc.ConfigError('config requires "session_name"')
if 'windows' not in sconf:
raise exc.ConfigError('config requires list of "windows"')
for window in sconf['windows']:
if 'window_name' not in window:
raise exc.ConfigError('config window is missing "window_name"')
return True
"""
Return True if config schema is correct.
Parameters
----------
sconf : dict
session configuration
Returns
-------
bool
"""
# verify session_name
if 'session_name' not in sconf:
raise exc.ConfigError('config requires "session_name"')
if 'windows' not in sconf:
raise exc.ConfigError('config requires list of "windows"')
for window in sconf['windows']:
if 'window_name' not in window:
raise exc.ConfigError('config window is missing "window_name"')
return True
from ._compat import implements_to_string
class TmuxpException(Exception):
"""Base Exception for Tmuxp Errors."""
class ConfigError(TmuxpException):
"""Error parsing tmuxp configuration dict."""
pass
class EmptyConfigException(ConfigError):
"""Configuration is empty."""
pass
class BeforeLoadScriptNotExists(OSError):
def __init__(self, *args, **kwargs):
super(BeforeLoadScriptNotExists, self).__init__(*args, **kwargs)
self.strerror = "before_script file '%s' doesn't exist." % self.strerror
@implements_to_string
class BeforeLoadScriptError(Exception):