@contextmanager
def set_env_proxy(self):
    my = self.yum_base()
    namepass = ''
    proxy_url = ''
    scheme = ['http', 'https']
    old_proxy_env = [os.getenv('http_proxy'), os.getenv('https_proxy')]
    try:
        if my.conf.proxy:
            if my.conf.proxy_username:
                namepass = (namepass + my.conf.proxy_username)
                proxy_url = my.conf.proxy
                if my.conf.proxy_password:
                    namepass = ((namepass + ':') + my.conf.proxy_password)
            elif ('@' in my.conf.proxy):
                namepass = my.conf.proxy.split('@')[0].split('//')[(- 1)]
                proxy_url = my.conf.proxy.replace('{0}@'.format(namepass), '')
            if namepass:
                namepass = (namepass + '@')
                for item in scheme:
                    os.environ[(item + '_proxy')] = re.sub('(http://)', ('\\1' + namepass), proxy_url)
        (yield)
    except yum.Errors.YumBaseError:
        raise
    finally:
        for item in scheme:
            if os.getenv('{0}_proxy'.format(item)):
                del os.environ['{0}_proxy'.format(item)]
        if old_proxy_env[0]:
            os.environ['http_proxy'] = old_proxy_env[0]
        if old_proxy_env[1]:
            os.environ['https_proxy'] = old_proxy_env[1]
@contextmanager
def set_env_proxy(self):
    my = self.yum_base()
    namepass = 
    proxy_url = 
    scheme = ['http', 'https']
    old_proxy_env = [os.getenv('http_proxy'), os.getenv('https_proxy')]
    try:
        if my.conf.proxy:
            if my.conf.proxy_username:
                namepass = (namepass + my.conf.proxy_username)
                proxy_url = my.conf.proxy
                if my.conf.proxy_password:
                    namepass = ((namepass + ':') + my.conf.proxy_password)
            elif ('@' in my.conf.proxy):
                namepass = my.conf.proxy.split('@')[0].split('//')[(- 1)]
                proxy_url = my.conf.proxy.replace('{0}@'.format(namepass), )
            if namepass:
                namepass = (namepass + '@')
                for item in scheme:
                    os.environ[(item + '_proxy')] = re.sub('(http://)', ('\\1' + namepass), proxy_url)
        (yield)
    except yum.Errors.YumBaseError:
        raise
    finally:
        for item in scheme:
            if os.getenv('{0}_proxy'.format(item)):
                del os.environ['{0}_proxy'.format(item)]
        if old_proxy_env[0]:
            os.environ['http_proxy'] = old_proxy_env[0]
        if old_proxy_env[1]:
            os.environ['https_proxy'] = old_proxy_env[1]