Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
yaml_config = loadfixture("workspacefreezer/sampleconfig.yaml")
sconfig = kaptan.Kaptan(handler='yaml')
sconfig = sconfig.import_config(yaml_config).get()
builder = WorkspaceBuilder(sconf=sconfig)
builder.build(session=session)
assert session == builder.session
time.sleep(0.50)
session = session
sconf = freeze(session)
config.validate_schema(sconf)
sconf = config.inline(sconf)
kaptanconf = kaptan.Kaptan()
kaptanconf = kaptanconf.import_config(sconf)
kaptanconf.export('json', indent=2)
kaptanconf.export('yaml', indent=2, default_flow_style=False, safe=True)
def test_inline_config():
""":meth:`config.inline()` shell commands list to string."""
test_config = config.inline(ibefore_config)
assert test_config == iafter_config
def test_export_yaml(tmpdir):
yaml_config_file = tmpdir.join('config.yaml')
configparser = kaptan.Kaptan()
sampleconfig = config.inline(fixtures.sampleconfig.sampleconfigdict)
configparser.import_config(sampleconfig)
yaml_config_data = configparser.export('yaml', indent=2, default_flow_style=False)
yaml_config_file.write(yaml_config_data)
new_config_data = load_config(str(yaml_config_file))
assert fixtures.sampleconfig.sampleconfigdict == new_config_data
try:
if session_name:
session = t.find_where({'session_name': session_name})
else:
session = t.list_sessions()[0]
if not session:
raise exc.TmuxpException('Session not found.')
except exc.TmuxpException as e:
print(e)
return
sconf = freeze(session)
configparser = kaptan.Kaptan()
newconfig = config.inline(sconf)
configparser.import_config(newconfig)
config_format = click.prompt(
'Convert to', value_proc=_validate_choices(['yaml', 'json']), default='yaml'
)
if config_format == 'yaml':
newconfig = configparser.export(
'yaml', indent=2, default_flow_style=False, safe=True
)
elif config_format == 'json':
newconfig = configparser.export('json', indent=2)
else:
sys.exit('Unknown config format.')
print(newconfig)
print(