コード例 #1
0
ファイル: shell_config.py プロジェクト: yudading/vex
def handle_shell_config(shell, vexrc, environ):
    """Carry out the logic of the --shell-config option.
    """
    from vex import shell_config
    data = shell_config.shell_config_for(shell, vexrc, environ)
    if not data:
        raise exceptions.OtherShell("unknown shell: {0!r}".format(shell))
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(data)
    else:
        sys.stdout.write(data)
    return 0
コード例 #2
0
ファイル: shell_config.py プロジェクト: cwacek/vex
def handle_shell_config(shell, vexrc, environ):
    """Carry out the logic of the --shell-config option.
    """
    from vex import shell_config
    data = shell_config.shell_config_for(shell, vexrc, environ)
    if not data:
        raise exceptions.OtherShell("unknown shell: {0!r}".format(shell))
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(data)
    else:
        sys.stdout.write(data)
    return 0
コード例 #3
0
ファイル: test_shell_config.py プロジェクト: yudading/vex
 def test_unknown_shell(self):
     vexrc = Vexrc()
     output = shell_config_for('unlikely_name', vexrc, {})
     assert output.strip() == b''
コード例 #4
0
ファイル: test_shell_config.py プロジェクト: yudading/vex
 def test_fish_config_scary(self):
     vexrc = Vexrc()
     output = shell_config_for("fish", vexrc, {'WORKON_HOME': '$x'})
     assert output
     assert b'$x' not in output
コード例 #5
0
ファイル: test_shell_config.py プロジェクト: yudading/vex
 def test_fish_config_not_scary(self):
     vexrc = Vexrc()
     with patch('os.path.exists', returnvalue=True):
         output = shell_config_for("fish", vexrc, {'WORKON_HOME': '/hoorj'})
     assert output
     assert b'/hoorj' in output
コード例 #6
0
ファイル: test_shell_config.py プロジェクト: yudading/vex
 def test_fish_config(self):
     vexrc = Vexrc()
     output = shell_config_for("fish", vexrc, {})
     assert output
コード例 #7
0
 def test_fish_config_scary(self):
     vexrc = Vexrc()
     output = shell_config_for("fish", vexrc, {"WORKON_HOME": "$x"})
     assert output
     assert b"$x" not in output
コード例 #8
0
 def test_fish_config_not_scary(self):
     vexrc = Vexrc()
     with patch("os.path.exists", returnvalue=True):
         output = shell_config_for("fish", vexrc, {"WORKON_HOME": "/hoorj"})
     assert output
     assert b"/hoorj" in output