Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Parameters
----------
sconf : dict
session config, includes a :py:obj:`list` of ``windows``.
server : :class:`libtmux.Server`
tmux server to build session in
Notes
-----
TODO: Initialize :class:`libtmux.Session` from here, in
``self.session``.
"""
if not sconf:
raise exc.EmptyConfigException('session configuration is empty.')
# config.validate_schema(sconf)
if isinstance(server, Server):
self.server = server
else:
self.server = None
self.sconf = sconf
def __init__(self, sconf, server=None):
"""Initialize workspace loading.
:todo: initialize :class:`Session` from here, in ``self.session``.
:param sconf: session config, includes a :py:obj:`list` of ``windows``.
:type sconf: :py:obj:`dict`
:param server:
:type server: :class:`Server`
"""
if not sconf:
raise exc.EmptyConfigException('session configuration is empty.')
# config.validate_schema(sconf)
if isinstance(server, Server):
self.server = server
else:
self.server = None
self.sconf = sconf
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
# support incremental session building or appending (yet, PR's welcome!)
if builder.session_exists(session_name):
if not detached and (
answer_yes
or click.confirm(
'%s is already running. Attach?'
% click.style(session_name, fg='green'),
default=True,
)
):