Exemple #1
0
def test_expandvars(inp, exp, xonsh_builtins):
    """Tweaked for xonsh cases from CPython `test_genericpath.py`"""
    env = Env(
        {"foo": "bar", "spam": "eggs", "a_bool": True, "an_int": 42, "none": None}
    )
    xonsh_builtins.__xonsh__.env = env
    assert expandvars(inp) == exp
Exemple #2
0
def test_expandvars(inp, exp, xonsh_builtins):
    """Tweaked for xonsh cases from CPython `test_genericpath.py`"""
    env = Env(
        {"foo": "bar", "spam": "eggs", "a_bool": True, "an_int": 42, "none": None}
    )
    xonsh_builtins.__xonsh__.env = env
    assert expandvars(inp) == exp
Exemple #3
0
def test_expandvars(inp, exp, xonsh_builtins):
    """Tweaked for xonsh cases from CPython `test_genericpath.py`"""
    env = Env({
        'foo': 'bar',
        'spam': 'eggs',
        'a_bool': True,
        'an_int': 42,
        'none': None
    })
    xonsh_builtins.__xonsh_env__ = env
    assert expandvars(inp) == exp
Exemple #4
0
def expand_path(s):
    """Takes a string path and expands ~ to home and environment vars."""
    if builtins.__xonsh_env__.get('EXPAND_ENV_VARS'):
        s = expandvars(s)
    # expand ~ according to Bash unquoted rules "Each variable assignment is
    # checked for unquoted tilde-prefixes immediately following a ':' or the
    # first '='". See the following for more details.
    # https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html
    pre, char, post = s.partition('=')
    s = pre + char + os.path.expanduser(post) if char else s
    s = os.pathsep.join(map(os.path.expanduser, s.split(os.pathsep)))
    return s
Exemple #5
0
def expand_path(s):
    """Takes a string path and expands ~ to home and environment vars."""
    if builtins.__xonsh_env__.get('EXPAND_ENV_VARS'):
        s = expandvars(s)
    # expand ~ according to Bash unquoted rules "Each variable assignment is
    # checked for unquoted tilde-prefixes immediately following a ':' or the
    # first '='". See the following for more details.
    # https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html
    pre, char, post = s.partition('=')
    if char:
        s = os.path.expanduser(pre) + char
        s += os.pathsep.join(map(os.path.expanduser, post.split(os.pathsep)))
    else:
        s = os.path.expanduser(s)
    return s
Exemple #6
0
def expand_path(s):
    """Takes a string path and expands ~ to home and environment vars."""
    if builtins.__xonsh_env__.get('EXPAND_ENV_VARS'):
        s = expandvars(s)
    return os.path.expanduser(s)
Exemple #7
0
def expand_path(s):
    """Takes a string path and expands ~ to home and environment vars."""
    global ENV
    if ENV.get('EXPAND_ENV_VARS'):
        s = expandvars(s)
    return os.path.expanduser(s)
Exemple #8
0
def expand_path(s):
    """Takes a string path and expands ~ to home and environment vars."""
    global ENV
    if ENV.get('EXPAND_ENV_VARS'):
        s = expandvars(s)
    return os.path.expanduser(s)
Exemple #9
0
def test_expandvars(inp, exp, xession):
    """Tweaked for xonsh cases from CPython `test_genericpath.py`"""
    xession.env.update(
        dict({"foo": "bar", "spam": "eggs", "a_bool": True, "an_int": 42, "none": None})
    )
    assert expandvars(inp) == exp
Exemple #10
0
def test_expandvars(inp, exp, xonsh_builtins):
    """Tweaked for xonsh cases from CPython `test_genericpath.py`"""
    env = Env({'foo':'bar', 'spam': 'eggs', 'a_bool': True, 'an_int': 42, 'none': None})
    xonsh_builtins.__xonsh_env__ = env
    assert expandvars(inp) == exp
Exemple #11
0
def expand_path(s):
    """Takes a string path and expands ~ to home and environment vars."""
    if builtins.__xonsh_env__.get('EXPAND_ENV_VARS'):
        s = expandvars(s)
    return os.path.expanduser(s)