1414logger = logging .getLogger (__name__ )
1515TMUXP_DIR = os .path .join (os .path .dirname (__file__ ), '.tmuxp' )
1616
17+ # todo, change 'root' to a cd or start_directory
18+
1719
1820def teamocil_to_tmuxp (sconf ):
1921 '''
@@ -35,12 +37,14 @@ def teamocil_to_tmuxp(sconf):
3537 tmuxp_config ['config' ] = sconf ['cli_args' ]
3638
3739 if '-f' in tmuxp_config ['config' ]:
38- tmuxp_config ['config' ] = tmuxp_config ['config' ].replace ('-f' , '' ).strip ()
40+ tmuxp_config ['config' ] = tmuxp_config [
41+ 'config' ].replace ('-f' , '' ).strip ()
3942 elif 'tmux_options' in sconf :
4043 tmuxp_config ['config' ] = sconf ['tmux_options' ]
4144
4245 if '-f' in tmuxp_config ['config' ]:
43- tmuxp_config ['config' ] = tmuxp_config ['config' ].replace ('-f' , '' ).strip ()
46+ tmuxp_config ['config' ] = tmuxp_config [
47+ 'config' ].replace ('-f' , '' ).strip ()
4448
4549 if 'socket_name' in sconf :
4650 tmuxp_config ['socket_name' ] = sconf ['socket_name' ]
@@ -98,7 +102,6 @@ def teamocil_to_tmuxp(sconf):
98102 return tmuxp_config
99103
100104
101-
102105class TeamocilTest (unittest .TestCase ):
103106
104107 teamocil_yaml = """\
@@ -340,86 +343,109 @@ class TeamocilLayoutsTest(unittest.TestCase):
340343
341344 teamocil_dict = {
342345 'two-windows' : {
343- 'windows' : [{
344- 'name' : 'foo' ,
345- 'clear' : True ,
346- 'root' : '/foo' ,
347- 'layout' : 'tiled' ,
348- 'panes' : [
349- {'cmd' : "echo 'foo'" },
350- {'cmd' : "echo 'foo again'" }
351- ]
352- },
346+ 'windows' : [
347+ {
348+ 'name' : 'foo' ,
349+ 'clear' : True ,
350+ 'root' : '/foo' ,
351+ 'layout' : 'tiled' ,
352+ 'panes' : [
353+ {
354+ 'cmd' : "echo 'foo'"
355+ },
356+ {
357+ 'cmd' : "echo 'foo again'"
358+ }
359+ ]
360+ },
353361 {
354362 'name' : 'bar' ,
355363 'root' : '/bar' ,
356364 'splits' : [
357- {'cmd' : [
358- "echo 'bar'" ,
359- "echo 'bar in an array'"
360- ],
361- 'target' : 'bottom-right'
362- },
363- {'cmd' : "echo 'bar again'" ,
364- 'focus' : True ,
365- 'width' : 50
366- }
365+ {
366+ 'cmd' : [
367+ "echo 'bar'" ,
368+ "echo 'bar in an array'"
369+ ],
370+ 'target' : 'bottom-right'
371+ },
372+ {
373+ 'cmd' : "echo 'bar again'" ,
374+ 'focus' : True ,
375+ 'width' : 50
376+ }
367377 ]
368378
369- }]
379+ }
380+ ]
370381 },
371382
372383 'two-windows-with-filters' : {
373- 'windows' : [{
374- 'name' : 'foo' ,
375- 'root' : '/foo' ,
376- 'filters' : {
377- 'before' : [
378- 'echo first before filter' ,
379- 'echo second before filter'
384+ 'windows' : [
385+ {
386+ 'name' : 'foo' ,
387+ 'root' : '/foo' ,
388+ 'filters' :
389+ {
390+ 'before' : [
391+ 'echo first before filter' ,
392+ 'echo second before filter'
380393 ],
381- 'after' : [
382- 'echo first after filter' ,
383- 'echo second after filter' ,
394+ 'after' : [
395+ 'echo first after filter' ,
396+ 'echo second after filter' ,
384397 ]
385- },
386- 'panes' : [
387- {'cmd' : "echo 'foo'" },
388- {'cmd' : "echo 'foo again'" , 'width' : 50 }
389- ]
390- }]
398+ },
399+ 'panes' : [
400+ {
401+ 'cmd' : "echo 'foo'"
402+ },
403+ {
404+ 'cmd' : "echo 'foo again'" ,
405+ 'width' : 50
406+ }
407+ ]
408+ }
409+ ]
391410 },
392411
393412 'two-windows-with-custom-command-options' : {
394- 'windows' : [{
395- 'name' : 'foo' ,
396- 'cmd_separator' : ' ' ,
397- 'with_env_var' : False ,
398- 'clear' : True ,
399- 'root' : '/foo' ,
400- 'layout' : 'tiled' ,
401- 'panes' : [
402- {'cmd' : "echo 'foo'" },
403- {'cmd' : "echo 'foo again'" }
413+ 'windows' : [
414+ {
415+ 'name' : 'foo' ,
416+ 'cmd_separator' : ' ' ,
417+ 'with_env_var' : False ,
418+ 'clear' : True ,
419+ 'root' : '/foo' ,
420+ 'layout' : 'tiled' ,
421+ 'panes' : [
422+ {
423+ 'cmd' : "echo 'foo'"
424+ },
425+ {
426+ 'cmd' : "echo 'foo again'"
427+ }
404428 ]
405- }, {
406- 'name' : 'bar' ,
407- 'cmd_separator' : ' && ' ,
408- 'with_env_var' : True ,
409- 'root' : '/bar' ,
410- 'splits' : [
411- {'cmd' : [
412- "echo 'bar'" ,
413- "echo 'bar in an array'"
414- ],
415- 'target' : 'bottom-right'
416- },
417- {'cmd' : "echo 'bar again'" ,
418- 'focus' : True ,
419- 'width' : 50
420- }
421- ]
422- }]
429+ }, {
430+ 'name' : 'bar' ,
431+ 'cmd_separator' : ' && ' ,
432+ 'with_env_var' : True ,
433+ 'root' : '/bar' ,
434+ 'splits' : [
435+ {
436+ 'cmd' : [
437+ "echo 'bar'" ,
438+ "echo 'bar in an array'"
439+ ],
440+ 'target' : 'bottom-right'
441+ },
442+ {
443+ 'cmd' : "echo 'bar again'" ,
444+ 'focus' : True ,
445+ 'width' : 50
446+ }
447+ ]
448+ }]
423449 },
424450
425451 'three-windows-within-a-session' : {
@@ -428,31 +454,72 @@ class TeamocilLayoutsTest(unittest.TestCase):
428454 'windows' : [
429455 {
430456 'name' : 'first window' ,
431- 'panes' : [{
432- 'cmd' : "echo 'foo'"
433- }]
457+ 'panes' : [
458+ {
459+ 'cmd' : "echo 'foo'"
460+ }
461+ ]
434462 }, {
435463 'name' : 'second window' ,
436- 'panes' : [{
437- 'cmd' : "echo 'foo'" }]
464+ 'panes' : [
465+ {
466+ 'cmd' : "echo 'foo'" }
467+ ]
438468 }, {
439469 'name' : 'third window' ,
440470 'panes' : [
441- {'cmd' : "echo 'foo'" }
471+ {
472+ 'cmd' : "echo 'foo'"
473+ }
442474 ]
443475 }
444476 ]
445477 }
446478 }
447479 }
448480
481+ tmuxp_yaml = [
482+ {
483+ 'session_name' : 'two-windows' ,
484+ 'windows' : [
485+ {
486+ 'window_name' : 'foo' ,
487+ 'clear' : True ,
488+ 'layout' : 'tiled' ,
489+ 'panes' : [
490+ {
491+ 'cmd' : "echo 'foo'"
492+ },
493+ {
494+ 'cmd' : "echo 'foo again'"
495+ }
496+ ]
497+ },
498+ {
499+ 'window_name' : 'bar' ,
500+ 'panes' : [
501+ {
502+ 'cmd' : [
503+ "echo 'bar'" ,
504+ "echo 'bar in an array'"
505+ ]
506+ }
507+ ]
508+ }
509+ ]
510+ },
511+ ]
512+
449513 def test_config_to_dict (self ):
450514 self .maxDiff = None
451515 configparser = kaptan .Kaptan (handler = 'yaml' )
452516 test_config = configparser .import_config (self .teamocil_yaml )
453517 yaml_to_dict = test_config .get ()
454518 self .assertDictEqual (yaml_to_dict , self .teamocil_dict )
455519
520+ self .assertDictEqual (teamocil_to_tmuxp (
521+ self .tmuxinator_dict ), self .tmuxp_dict )
522+
456523 ''' this configuration contains multiple sessions in a single file.
457524 tmuxp can split them into files, proceed?
458525 '''
0 commit comments