pygears_tools/utils.py
def shell_source(script):
    """Sometime you want to emulate the action of "source" in bash,
    settings some environment variables. Here is a way to do it."""

    pipe = subprocess.Popen(". %s; env" % script,
                            stdout=subprocess.PIPE,
                            shell=True,
                            executable="/bin/bash" if os_name() == 'ubuntu' else None)
    output = pipe.communicate()[0].decode()
    env = {}
    for line in output.splitlines():
        try:
            keyval = line.split("=", 1)
            env[keyval[0]] = keyval[1]
        except:
            pass

    os.environ.update(env)
Sometime you want to emulate the action of "source" in bash,
    settings some environment variables. Here is a way to do it.
Sometime you want to emulate the action of "source" in bash,
settings some environment variables. Here is a way to do it.
Sometime you want to emulate the action of " source " in bash settings some environment variables . Here is a way to do it .
def shell_source(script):
    pipe = subprocess.Popen(". %s; env" % script,
                            stdout=subprocess.PIPE,
                            shell=True,
                            executable="/bin/bash" if os_name() == 'ubuntu' else None)
    output = pipe.communicate()[0].decode()
    env = {}
    for line in output.splitlines():
        try:
            keyval = line.split("=", 1)
            env[keyval[0]] = keyval[1]
        except:
            pass
    os.environ.update(env)
def shell_source ( script ) : pipe = subprocess . Popen ( ". %s; env" % script , stdout = subprocess . PIPE , shell = True , executable = "/bin/bash" if os_name ( ) == 'ubuntu' else None ) output = pipe . communicate ( ) [ 0 ] . decode ( ) env = { } for line in output . splitlines ( ) : try : keyval = line . split ( "=" , 1 ) env [ keyval [ 0 ] ] = keyval [ 1 ] except : pass os . environ . update ( env )
Sometime you want to emulate the action of "source" in bash,
settings some environment variables.
Sometime you want to emulate the action of " source " in bash settings some environment variables .
"""Sometime you want to emulate the action of "source" in bash,
    settings some environment variables. Here is a way to do it."""
script