def get_value(name, default_value=None, path=os.curdir, print_warnings=True):
    value = None
    term = get_term()

    if name == VALUE_WERCKER_URL:
        value = os.getenv("wercker_url", None)
        if value is None:
            value = os.getenv(ENV_KEY_WERCKER_URL, DEFAULT_WERCKER_URL)

        return value

    elif name == VALUE_MIXPANEL_TOKEN:
        value = os.getenv(ENV_KEY_MIXPANEL_TOKEN, DEFAULT_MIXPANEL_TOKEN)

    elif name == VALUE_USER_TOKEN:

        wercker_url = get_value(VALUE_WERCKER_URL)
        url = urlparse(wercker_url)

        file = _get_or_create_netrc_location()
        rc = netrc.netrc(file)

        if url.hostname in rc.hosts:
            value = rc.hosts[url.hostname][2]

    elif name == VALUE_USER_NAME:

        wercker_url = get_value(VALUE_WERCKER_URL)
        url = urlparse(wercker_url)

        file = _get_or_create_netrc_location()
        rc = netrc.netrc(file)

        if url.hostname in rc.hosts:
            value = rc.hosts[url.hostname][0]

    elif name == VALUE_HEROKU_TOKEN:

        file = _get_or_create_netrc_location()
        rc = netrc.netrc(file)

        result = rc.authenticators('api.heroku.com')
        if result and len(result) == 3:
            value = result[2]

    elif name == VALUE_PROJECT_ID:
        # from paths import find_git_root

        path = find_git_root(path)

        if not path:
            if print_warnings:
                puts(
                    term.red("Warning:") +
                    " Could not find a git repository."
                )
            return

        file = os.path.join(
            path,
            DEFAULT_DOT_WERCKER_NAME
        )

        if not os.path.isfile(file):
            if print_warnings:
                puts(
                    term.yellow("Warning:") +
                    " Could not find a %s file in the application root" %
                    DEFAULT_DOT_WERCKER_NAME
                )

            return

        Config = ConfigParser.ConfigParser()

        Config.read(file)

        try:
            value = Config.get('project', 'id')
        except (
            ConfigParser.NoOptionError,
            ConfigParser.NoSectionError
        ):
            value = None

    elif name == VALUE_DISPLAY_DEBUG:
        env_value = os.environ.get(ENV_KEY_DISPLAY_DEBUG)

        if env_value is not None and env_value.lower() == "true":
            value = True
        else:
            value = DEFAULT_DISPLAY_DEBUG

    return value
dataset/ETHPy150Open wercker/wercker-cli/werckercli/config.py/get_value/original