{
    "file_diffs": [
        {
            "old_file_content": "# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n# ex: set sts=4 ts=4 sw=4 noet:\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n#\n#   See COPYING file distributed along with the datalad package for the\n#   copyright and license terms.\n#\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n\"\"\"Definitions for ansi colors etc\"\"\"\n\nimport os\nfrom .. import cfg\nfrom ..ui import ui\n\nBLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)\nBOLD = 1\nUNDERLINE = 4\n\nRESET_SEQ = \"\\033[0m\"\nCOLOR_SEQ = \"\\033[1;%dm\"\nBOLD_SEQ = \"\\033[1m\"\n\nLOG_LEVEL_COLORS = {\n    'WARNING': YELLOW,\n    'INFO': None,\n    'DEBUG': BLUE,\n    'CRITICAL': YELLOW,\n    'ERROR': RED\n}\n\nRESULT_STATUS_COLORS = {\n    'ok': GREEN,\n    'notneeded': GREEN,\n    'impossible': YELLOW,\n    'error': RED\n}\n\n# Aliases for uniform presentation\n\nDATASET = UNDERLINE\nFIELD = BOLD\n\n\ndef color_enabled():\n    \"\"\"Check for whether color output is enabled\n\n    Color is only enabled if the terminal is interactive.\n    If the datalad.ui.color configuration setting is 'on' or 'off', then\n    respect that.\n    If the datalad.ui.color setting is 'auto' (default), then color is\n    enabled unless the environment variable NO_COLOR is defined.\n\n    Returns\n    -------\n    bool\n    \"\"\"\n    if not ui.is_interactive:\n        return False\n\n    ui_color = cfg.obtain('datalad.ui.color')\n    if ui_color == 'off':\n        return False\n\n    return ui_color == 'on' or os.getenv('NO_COLOR') is None\n\n\ndef format_msg(fmt, use_color=False):\n    \"\"\"Replace $RESET and $BOLD with corresponding ANSI entries\"\"\"\n    if color_enabled() and use_color:\n        return fmt.replace(\"$RESET\", RESET_SEQ).replace(\"$BOLD\", BOLD_SEQ)\n    else:\n        return fmt.replace(\"$RESET\", \"\").replace(\"$BOLD\", \"\")\n\n\ndef color_word(s, color, force=False):\n    \"\"\"Color `s` with `color`.\n\n    Parameters\n    ----------\n    s : string\n    color : int\n        Code for color. If the value evaluates to false, the string will not be\n        colored.\n    force : boolean, optional\n        Color string even when non-interactive session is detected.\n\n    Returns\n    -------\n    str\n    \"\"\"\n    if color and (force or color_enabled()):\n        return \"%s%s%s\" % (COLOR_SEQ % color, s, RESET_SEQ)\n    return s\n\n\ndef color_status(status):\n    return color_word(status, RESULT_STATUS_COLORS.get(status))\n",
            "new_file_content": "# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n# ex: set sts=4 ts=4 sw=4 noet:\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n#\n#   See COPYING file distributed along with the datalad package for the\n#   copyright and license terms.\n#\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n\"\"\"Definitions for ansi colors etc\"\"\"\n\nimport os\nfrom .. import cfg\nfrom ..ui import ui\n\nBLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)\nBOLD = 1\nUNDERLINE = 4\n\nRESET_SEQ = \"\\033[0m\"\nCOLOR_SEQ = \"\\033[1;%dm\"\nBOLD_SEQ = \"\\033[1m\"\n\nLOG_LEVEL_COLORS = {\n    'WARNING': YELLOW,\n    'INFO': None,\n    'DEBUG': BLUE,\n    'CRITICAL': YELLOW,\n    'ERROR': RED\n}\n\nRESULT_STATUS_COLORS = {\n    'ok': GREEN,\n    'notneeded': GREEN,\n    'impossible': YELLOW,\n    'error': RED\n}\n\n# Aliases for uniform presentation\n\nDATASET = UNDERLINE\nFIELD = BOLD\n\n\ndef color_enabled():\n    \"\"\"Check for whether color output is enabled\n\n    If the configuration value ``datalad.ui.color`` is ``'on'`` or ``'off'``,\n    that takes precedence.\n    If ``datalad.ui.color`` is ``'auto'``, and the environment variable\n    ``NO_COLOR`` is defined (see https://no-color.org), then color is disabled.\n    Otherwise, enable colors if a TTY is detected by ``datalad.ui.ui.is_interactive``.\n\n    Returns\n    -------\n    bool\n    \"\"\"\n    ui_color = cfg.obtain('datalad.ui.color')\n    return (ui_color == 'on' or\n            ui_color == 'auto' and os.getenv('NO_COLOR') is None and ui.is_interactive)\n\n\ndef format_msg(fmt, use_color=False):\n    \"\"\"Replace $RESET and $BOLD with corresponding ANSI entries\"\"\"\n    if color_enabled() and use_color:\n        return fmt.replace(\"$RESET\", RESET_SEQ).replace(\"$BOLD\", BOLD_SEQ)\n    else:\n        return fmt.replace(\"$RESET\", \"\").replace(\"$BOLD\", \"\")\n\n\ndef color_word(s, color, force=False):\n    \"\"\"Color `s` with `color`.\n\n    Parameters\n    ----------\n    s : string\n    color : int\n        Code for color. If the value evaluates to false, the string will not be\n        colored.\n    force : boolean, optional\n        Color string even when non-interactive session is detected.\n\n    Returns\n    -------\n    str\n    \"\"\"\n    if color and (force or color_enabled()):\n        return \"%s%s%s\" % (COLOR_SEQ % color, s, RESET_SEQ)\n    return s\n\n\ndef color_status(status):\n    return color_word(status, RESULT_STATUS_COLORS.get(status))\n",
            "header": {
                "file": {
                    "path": "datalad/support/ansi_colors.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "eae5e691a",
                "new_commit_hash": "2be222611",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/datalad/support/ansi_colors.py"
            },
            "plus_file": {
                "path": "b/datalad/support/ansi_colors.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 44,
                            "length": 24
                        },
                        "new_range": {
                            "start": 44,
                            "length": 19
                        },
                        "section": "FIELD = BOLD"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "def color_enabled():",
                                "type": "context"
                            },
                            {
                                "content": "    \"\"\"Check for whether color output is enabled",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    Color is only enabled if the terminal is interactive.",
                                "type": "deleted"
                            },
                            {
                                "content": "    If the datalad.ui.color configuration setting is 'on' or 'off', then",
                                "type": "deleted"
                            },
                            {
                                "content": "    respect that.",
                                "type": "deleted"
                            },
                            {
                                "content": "    If the datalad.ui.color setting is 'auto' (default), then color is",
                                "type": "deleted"
                            },
                            {
                                "content": "    enabled unless the environment variable NO_COLOR is defined.",
                                "type": "deleted"
                            },
                            {
                                "content": "    If the configuration value ``datalad.ui.color`` is ``'on'`` or ``'off'``,",
                                "type": "added"
                            },
                            {
                                "content": "    that takes precedence.",
                                "type": "added"
                            },
                            {
                                "content": "    If ``datalad.ui.color`` is ``'auto'``, and the environment variable",
                                "type": "added"
                            },
                            {
                                "content": "    ``NO_COLOR`` is defined (see https://no-color.org), then color is disabled.",
                                "type": "added"
                            },
                            {
                                "content": "    Otherwise, enable colors if a TTY is detected by ``datalad.ui.ui.is_interactive``.",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    Returns",
                                "type": "context"
                            },
                            {
                                "content": "    -------",
                                "type": "context"
                            },
                            {
                                "content": "    bool",
                                "type": "context"
                            },
                            {
                                "content": "    \"\"\"",
                                "type": "context"
                            },
                            {
                                "content": "    if not ui.is_interactive:",
                                "type": "deleted"
                            },
                            {
                                "content": "        return False",
                                "type": "deleted"
                            },
                            {
                                "content": "",
                                "type": "deleted"
                            },
                            {
                                "content": "    ui_color = cfg.obtain('datalad.ui.color')",
                                "type": "context"
                            },
                            {
                                "content": "    if ui_color == 'off':",
                                "type": "deleted"
                            },
                            {
                                "content": "        return False",
                                "type": "deleted"
                            },
                            {
                                "content": "",
                                "type": "deleted"
                            },
                            {
                                "content": "    return ui_color == 'on' or os.getenv('NO_COLOR') is None",
                                "type": "deleted"
                            },
                            {
                                "content": "    return (ui_color == 'on' or",
                                "type": "added"
                            },
                            {
                                "content": "            ui_color == 'auto' and os.getenv('NO_COLOR') is None and ui.is_interactive)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def format_msg(fmt, use_color=False):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "datalad/support/ansi_colors.py",
                            "type": "function",
                            "name": "color_enabled",
                            "content": "def color_enabled():\n    \"\"\"Check for whether color output is enabled\n\n    Color is only enabled if the terminal is interactive.\n    If the datalad.ui.color configuration setting is 'on' or 'off', then\n    respect that.\n    If the datalad.ui.color setting is 'auto' (default), then color is\n    enabled unless the environment variable NO_COLOR is defined.\n\n    Returns\n    -------\n    bool\n    \"\"\"\n    if not ui.is_interactive:\n        return False\n\n    ui_color = cfg.obtain('datalad.ui.color')\n    if ui_color == 'off':\n        return False\n\n    return ui_color == 'on' or os.getenv('NO_COLOR') is None",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 44,
                            "end_lineno": 64,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n# ex: set sts=4 ts=4 sw=4 noet:\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n#\n#   See COPYING file distributed along with the datalad package for the\n#   copyright and license terms.\n#\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n\"\"\"Test ANSI color tools \"\"\"\n\nimport os\nfrom mock import patch\nfrom datalad.tests.utils import assert_equal\nfrom datalad.tests.utils import patch_config\n\nfrom datalad.support import ansi_colors as colors\n\n\ndef test_color_enabled():\n    # In the absence of NO_COLOR, default to enable, failing if non-interactive terminal\n    # or ui.color is off\n    with patch.dict(os.environ):\n        os.environ.pop('NO_COLOR', None)\n        with patch('datalad.support.ansi_colors.ui'):\n            colors.ui.is_interactive = False\n            for ui_color in ('on', 'off', 'auto'):\n                with patch_config({'datalad.ui.color': ui_color}):\n                    assert_equal(colors.color_enabled(), False)\n        with patch('datalad.support.ansi_colors.ui'):\n            colors.ui.is_interactive = True\n            with patch_config({'datalad.ui.color': 'off'}):\n                assert_equal(colors.color_enabled(), False)\n            for ui_color in ('on', 'auto'):\n                with patch_config({'datalad.ui.color': ui_color}):\n                    assert_equal(colors.color_enabled(), True)\n\n    # In the presence of NO_COLOR, default to disable, unless terminal is interactive\n    # and ui.color is on\n    # The value of NO_COLOR should have no effect\n    for NO_COLOR in (\"\", \"1\", \"0\"):\n        with patch.dict(os.environ, {'NO_COLOR': NO_COLOR}):\n            with patch('datalad.support.ansi_colors.ui'):\n                colors.ui.is_interactive = False\n                for ui_color in ('on', 'off', 'auto'):\n                    with patch_config({'datalad.ui.color': ui_color}):\n                        assert_equal(colors.color_enabled(), False)\n            with patch('datalad.support.ansi_colors.ui'):\n                colors.ui.is_interactive = True\n                with patch_config({'datalad.ui.color': 'on'}):\n                    assert_equal(colors.color_enabled(), True)\n                for ui_color in ('off', 'auto'):\n                    with patch_config({'datalad.ui.color': ui_color}):\n                        assert_equal(colors.color_enabled(), False)\n\n#\n# In all other tests, just patch color_enabled\n#\n\n\ndef test_format_msg():\n    fmt = r'a$BOLDb$RESETc$BOLDd$RESETe'\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            assert_equal(colors.format_msg(fmt), 'abcde')\n            assert_equal(colors.format_msg(fmt, use_color=False), 'abcde')\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: False):\n        for use_color in (True, False):\n            assert_equal(colors.format_msg(fmt), 'abcde')\n            assert_equal(colors.format_msg(fmt, use_color=use_color), 'abcde')\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: True):\n        assert_equal(colors.format_msg(fmt, use_color=True), 'a\\033[1mb\\033[0mc\\033[1md\\033[0me')\n\n\ndef test_color_word():\n    s = 'word'\n    green_s = '\\033[1;32mword\\033[0m'\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            assert_equal(colors.color_word(s, colors.GREEN, force=True), green_s)\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: True):\n        assert_equal(colors.color_word(s, colors.GREEN), green_s)\n        assert_equal(colors.color_word(s, colors.GREEN, force=False), green_s)\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: False):\n        assert_equal(colors.color_word(s, colors.GREEN), s)\n        assert_equal(colors.color_word(s, colors.GREEN, force=False), s)\n\n\ndef test_color_status():\n    # status -> (plain, colored)\n    statuses = {\n        'ok': ('ok', '\\033[1;32mok\\033[0m'),\n        'notneeded': ('notneeded', '\\033[1;32mnotneeded\\033[0m'),\n        'impossible': ('impossible', '\\033[1;33mimpossible\\033[0m'),\n        'error': ('error', '\\033[1;31merror\\033[0m'),\n        'invalid': ('invalid', 'invalid'),\n        }\n\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            for status, retopts in statuses.items():\n                assert_equal(colors.color_status(status), retopts[enabled])\n",
            "new_file_content": "# emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n# ex: set sts=4 ts=4 sw=4 noet:\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n#\n#   See COPYING file distributed along with the datalad package for the\n#   copyright and license terms.\n#\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n\"\"\"Test ANSI color tools \"\"\"\n\nimport os\nfrom mock import patch\nfrom datalad.tests.utils import assert_equal\nfrom datalad.tests.utils import patch_config\n\nfrom datalad.support import ansi_colors as colors\n\n\ndef test_color_enabled():\n    # In the absence of NO_COLOR, follow ui.color, or ui.is_interactive if 'auto'\n    with patch.dict(os.environ), \\\n         patch('datalad.support.ansi_colors.ui'):\n        os.environ.pop('NO_COLOR', None)\n        for is_interactive in (True, False):\n            colors.ui.is_interactive = is_interactive\n            with patch_config({'datalad.ui.color': 'off'}):\n                assert_equal(colors.color_enabled(), False)\n            with patch_config({'datalad.ui.color': 'on'}):\n                assert_equal(colors.color_enabled(), True)\n            with patch_config({'datalad.ui.color': 'auto'}):\n                assert_equal(colors.color_enabled(), is_interactive)\n\n    # In the presence of NO_COLOR, default to disable, unless ui.color is \"on\"\n    # The value of NO_COLOR should have no effect, so try true-ish and false-ish values\n    for NO_COLOR in (\"\", \"1\", \"0\"):\n        with patch.dict(os.environ, {'NO_COLOR': NO_COLOR}), \\\n             patch('datalad.support.ansi_colors.ui'):\n            for is_interactive in (True, False):\n                colors.ui.is_interactive = is_interactive\n                with patch_config({'datalad.ui.color': 'on'}):\n                    assert_equal(colors.color_enabled(), True)\n                for ui_color in ('off', 'auto'):\n                    with patch_config({'datalad.ui.color': ui_color}):\n                        assert_equal(colors.color_enabled(), False)\n\n#\n# In all other tests, just patch color_enabled\n#\n\n\ndef test_format_msg():\n    fmt = r'a$BOLDb$RESETc$BOLDd$RESETe'\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            assert_equal(colors.format_msg(fmt), 'abcde')\n            assert_equal(colors.format_msg(fmt, use_color=False), 'abcde')\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: False):\n        for use_color in (True, False):\n            assert_equal(colors.format_msg(fmt), 'abcde')\n            assert_equal(colors.format_msg(fmt, use_color=use_color), 'abcde')\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: True):\n        assert_equal(colors.format_msg(fmt, use_color=True), 'a\\033[1mb\\033[0mc\\033[1md\\033[0me')\n\n\ndef test_color_word():\n    s = 'word'\n    green_s = '\\033[1;32mword\\033[0m'\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            assert_equal(colors.color_word(s, colors.GREEN, force=True), green_s)\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: True):\n        assert_equal(colors.color_word(s, colors.GREEN), green_s)\n        assert_equal(colors.color_word(s, colors.GREEN, force=False), green_s)\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: False):\n        assert_equal(colors.color_word(s, colors.GREEN), s)\n        assert_equal(colors.color_word(s, colors.GREEN, force=False), s)\n\n\ndef test_color_status():\n    # status -> (plain, colored)\n    statuses = {\n        'ok': ('ok', '\\033[1;32mok\\033[0m'),\n        'notneeded': ('notneeded', '\\033[1;32mnotneeded\\033[0m'),\n        'impossible': ('impossible', '\\033[1;33mimpossible\\033[0m'),\n        'error': ('error', '\\033[1;31merror\\033[0m'),\n        'invalid': ('invalid', 'invalid'),\n        }\n\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            for status, retopts in statuses.items():\n                assert_equal(colors.color_status(status), retopts[enabled])\n",
            "header": {
                "file": {
                    "path": "datalad/support/tests/test_ansi_colors.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "e0dcc1522",
                "new_commit_hash": "5a7b450ef",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/datalad/support/tests/test_ansi_colors.py"
            },
            "plus_file": {
                "path": "b/datalad/support/tests/test_ansi_colors.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 17,
                            "length": 35
                        },
                        "new_range": {
                            "start": 17,
                            "length": 26
                        },
                        "section": "from datalad.support import ansi_colors as colors"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def test_color_enabled():",
                                "type": "context"
                            },
                            {
                                "content": "    # In the absence of NO_COLOR, default to enable, failing if non-interactive terminal",
                                "type": "deleted"
                            },
                            {
                                "content": "    # or ui.color is off",
                                "type": "deleted"
                            },
                            {
                                "content": "    with patch.dict(os.environ):",
                                "type": "deleted"
                            },
                            {
                                "content": "    # In the absence of NO_COLOR, follow ui.color, or ui.is_interactive if 'auto'",
                                "type": "added"
                            },
                            {
                                "content": "    with patch.dict(os.environ), \\",
                                "type": "added"
                            },
                            {
                                "content": "         patch('datalad.support.ansi_colors.ui'):",
                                "type": "added"
                            },
                            {
                                "content": "        os.environ.pop('NO_COLOR', None)",
                                "type": "context"
                            },
                            {
                                "content": "        with patch('datalad.support.ansi_colors.ui'):",
                                "type": "deleted"
                            },
                            {
                                "content": "            colors.ui.is_interactive = False",
                                "type": "deleted"
                            },
                            {
                                "content": "            for ui_color in ('on', 'off', 'auto'):",
                                "type": "deleted"
                            },
                            {
                                "content": "                with patch_config({'datalad.ui.color': ui_color}):",
                                "type": "deleted"
                            },
                            {
                                "content": "                    assert_equal(colors.color_enabled(), False)",
                                "type": "deleted"
                            },
                            {
                                "content": "        with patch('datalad.support.ansi_colors.ui'):",
                                "type": "deleted"
                            },
                            {
                                "content": "            colors.ui.is_interactive = True",
                                "type": "deleted"
                            },
                            {
                                "content": "        for is_interactive in (True, False):",
                                "type": "added"
                            },
                            {
                                "content": "            colors.ui.is_interactive = is_interactive",
                                "type": "added"
                            },
                            {
                                "content": "            with patch_config({'datalad.ui.color': 'off'}):",
                                "type": "context"
                            },
                            {
                                "content": "                assert_equal(colors.color_enabled(), False)",
                                "type": "context"
                            },
                            {
                                "content": "            for ui_color in ('on', 'auto'):",
                                "type": "deleted"
                            },
                            {
                                "content": "                with patch_config({'datalad.ui.color': ui_color}):",
                                "type": "deleted"
                            },
                            {
                                "content": "                    assert_equal(colors.color_enabled(), True)",
                                "type": "deleted"
                            },
                            {
                                "content": "            with patch_config({'datalad.ui.color': 'on'}):",
                                "type": "added"
                            },
                            {
                                "content": "                assert_equal(colors.color_enabled(), True)",
                                "type": "added"
                            },
                            {
                                "content": "            with patch_config({'datalad.ui.color': 'auto'}):",
                                "type": "added"
                            },
                            {
                                "content": "                assert_equal(colors.color_enabled(), is_interactive)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    # In the presence of NO_COLOR, default to disable, unless terminal is interactive",
                                "type": "deleted"
                            },
                            {
                                "content": "    # and ui.color is on",
                                "type": "deleted"
                            },
                            {
                                "content": "    # The value of NO_COLOR should have no effect",
                                "type": "deleted"
                            },
                            {
                                "content": "    # In the presence of NO_COLOR, default to disable, unless ui.color is \"on\"",
                                "type": "added"
                            },
                            {
                                "content": "    # The value of NO_COLOR should have no effect, so try true-ish and false-ish values",
                                "type": "added"
                            },
                            {
                                "content": "    for NO_COLOR in (\"\", \"1\", \"0\"):",
                                "type": "context"
                            },
                            {
                                "content": "        with patch.dict(os.environ, {'NO_COLOR': NO_COLOR}):",
                                "type": "deleted"
                            },
                            {
                                "content": "            with patch('datalad.support.ansi_colors.ui'):",
                                "type": "deleted"
                            },
                            {
                                "content": "                colors.ui.is_interactive = False",
                                "type": "deleted"
                            },
                            {
                                "content": "                for ui_color in ('on', 'off', 'auto'):",
                                "type": "deleted"
                            },
                            {
                                "content": "                    with patch_config({'datalad.ui.color': ui_color}):",
                                "type": "deleted"
                            },
                            {
                                "content": "                        assert_equal(colors.color_enabled(), False)",
                                "type": "deleted"
                            },
                            {
                                "content": "            with patch('datalad.support.ansi_colors.ui'):",
                                "type": "deleted"
                            },
                            {
                                "content": "                colors.ui.is_interactive = True",
                                "type": "deleted"
                            },
                            {
                                "content": "        with patch.dict(os.environ, {'NO_COLOR': NO_COLOR}), \\",
                                "type": "added"
                            },
                            {
                                "content": "             patch('datalad.support.ansi_colors.ui'):",
                                "type": "added"
                            },
                            {
                                "content": "            for is_interactive in (True, False):",
                                "type": "added"
                            },
                            {
                                "content": "                colors.ui.is_interactive = is_interactive",
                                "type": "added"
                            },
                            {
                                "content": "                with patch_config({'datalad.ui.color': 'on'}):",
                                "type": "context"
                            },
                            {
                                "content": "                    assert_equal(colors.color_enabled(), True)",
                                "type": "context"
                            },
                            {
                                "content": "                for ui_color in ('off', 'auto'):",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "datalad/support/tests/test_ansi_colors.py",
                            "type": "function",
                            "name": "test_color_enabled",
                            "content": "def test_color_enabled():\n    # In the absence of NO_COLOR, default to enable, failing if non-interactive terminal\n    # or ui.color is off\n    with patch.dict(os.environ):\n        os.environ.pop('NO_COLOR', None)\n        with patch('datalad.support.ansi_colors.ui'):\n            colors.ui.is_interactive = False\n            for ui_color in ('on', 'off', 'auto'):\n                with patch_config({'datalad.ui.color': ui_color}):\n                    assert_equal(colors.color_enabled(), False)\n        with patch('datalad.support.ansi_colors.ui'):\n            colors.ui.is_interactive = True\n            with patch_config({'datalad.ui.color': 'off'}):\n                assert_equal(colors.color_enabled(), False)\n            for ui_color in ('on', 'auto'):\n                with patch_config({'datalad.ui.color': ui_color}):\n                    assert_equal(colors.color_enabled(), True)\n\n    # In the presence of NO_COLOR, default to disable, unless terminal is interactive\n    # and ui.color is on\n    # The value of NO_COLOR should have no effect\n    for NO_COLOR in (\"\", \"1\", \"0\"):\n        with patch.dict(os.environ, {'NO_COLOR': NO_COLOR}):\n            with patch('datalad.support.ansi_colors.ui'):\n                colors.ui.is_interactive = False\n                for ui_color in ('on', 'off', 'auto'):\n                    with patch_config({'datalad.ui.color': ui_color}):\n                        assert_equal(colors.color_enabled(), False)\n            with patch('datalad.support.ansi_colors.ui'):\n                colors.ui.is_interactive = True\n                with patch_config({'datalad.ui.color': 'on'}):\n                    assert_equal(colors.color_enabled(), True)\n                for ui_color in ('off', 'auto'):\n                    with patch_config({'datalad.ui.color': ui_color}):\n                        assert_equal(colors.color_enabled(), False)",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 19,
                            "end_lineno": 53,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "ae60a378de415bbd1039eef3719ff04b4266a4af^",
    "new_commit_hash": "ae60a378de415bbd1039eef3719ff04b4266a4af",
    "commit_message": "RF: Set precedence to datalad.ui.color, NO_COLOR, datalad.ui.ui.is_interactive",
    "commit_date": "2019-05-15T15:31:57-04:00",
    "metadata": {}
}
{
    "repo_name": "datalad",
    "new_commit_hash": "ae60a378de415bbd1039eef3719ff04b4266a4af",
    "test_file_codes": [
        "# emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n# ex: set sts=4 ts=4 sw=4 noet:\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n#\n#   See COPYING file distributed along with the datalad package for the\n#   copyright and license terms.\n#\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n\"\"\"Test ANSI color tools \"\"\"\n\nimport os\nfrom mock import patch\nfrom datalad.tests.utils import assert_equal\nfrom datalad.tests.utils import patch_config\n\nfrom datalad.support import ansi_colors as colors\n\n\ndef test_color_enabled():\n    # In the absence of NO_COLOR, follow ui.color, or ui.is_interactive if 'auto'\n    with patch.dict(os.environ), \\\n         patch('datalad.support.ansi_colors.ui'):\n        os.environ.pop('NO_COLOR', None)\n        for is_interactive in (True, False):\n            colors.ui.is_interactive = is_interactive\n            with patch_config({'datalad.ui.color': 'off'}):\n                assert_equal(colors.color_enabled(), False)\n            with patch_config({'datalad.ui.color': 'on'}):\n                assert_equal(colors.color_enabled(), True)\n            with patch_config({'datalad.ui.color': 'auto'}):\n                assert_equal(colors.color_enabled(), is_interactive)\n\n    # In the presence of NO_COLOR, default to disable, unless ui.color is \"on\"\n    # The value of NO_COLOR should have no effect, so try true-ish and false-ish values\n    for NO_COLOR in (\"\", \"1\", \"0\"):\n        with patch.dict(os.environ, {'NO_COLOR': NO_COLOR}), \\\n             patch('datalad.support.ansi_colors.ui'):\n            for is_interactive in (True, False):\n                colors.ui.is_interactive = is_interactive\n                with patch_config({'datalad.ui.color': 'on'}):\n                    assert_equal(colors.color_enabled(), True)\n                for ui_color in ('off', 'auto'):\n                    with patch_config({'datalad.ui.color': ui_color}):\n                        assert_equal(colors.color_enabled(), False)\n\n#\n# In all other tests, just patch color_enabled\n#\n\n\ndef test_format_msg():\n    fmt = r'a$BOLDb$RESETc$BOLDd$RESETe'\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            assert_equal(colors.format_msg(fmt), 'abcde')\n            assert_equal(colors.format_msg(fmt, use_color=False), 'abcde')\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: False):\n        for use_color in (True, False):\n            assert_equal(colors.format_msg(fmt), 'abcde')\n            assert_equal(colors.format_msg(fmt, use_color=use_color), 'abcde')\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: True):\n        assert_equal(colors.format_msg(fmt, use_color=True), 'a\\033[1mb\\033[0mc\\033[1md\\033[0me')\n\n\ndef test_color_word():\n    s = 'word'\n    green_s = '\\033[1;32mword\\033[0m'\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            assert_equal(colors.color_word(s, colors.GREEN, force=True), green_s)\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: True):\n        assert_equal(colors.color_word(s, colors.GREEN), green_s)\n        assert_equal(colors.color_word(s, colors.GREEN, force=False), green_s)\n\n    with patch('datalad.support.ansi_colors.color_enabled', lambda: False):\n        assert_equal(colors.color_word(s, colors.GREEN), s)\n        assert_equal(colors.color_word(s, colors.GREEN, force=False), s)\n\n\ndef test_color_status():\n    # status -> (plain, colored)\n    statuses = {\n        'ok': ('ok', '\\033[1;32mok\\033[0m'),\n        'notneeded': ('notneeded', '\\033[1;32mnotneeded\\033[0m'),\n        'impossible': ('impossible', '\\033[1;33mimpossible\\033[0m'),\n        'error': ('error', '\\033[1;31merror\\033[0m'),\n        'invalid': ('invalid', 'invalid'),\n        }\n\n    for enabled in (True, False):\n        with patch('datalad.support.ansi_colors.color_enabled', lambda: enabled):\n            for status, retopts in statuses.items():\n                assert_equal(colors.color_status(status), retopts[enabled])\n",
        "import pytest\nimport tempfile\nimport os\n\n\n@pytest.fixture\ndef path():\n    with tempfile.TemporaryDirectory() as tmpdir:\n        yield tmpdir\n\n\n@pytest.fixture(autouse=True)\ndef setup_git_config():\n    with tempfile.TemporaryDirectory() as home:\n        old_home = os.environ.get(\"HOME\")\n        os.environ[\"HOME\"] = home\n        os.system('git config --global user.name \"DataLad Tester\"')\n        os.system('git config --global user.email \"test@example.com\"')\n        yield\n        if old_home:\n            os.environ[\"HOME\"] = old_home\n"
    ],
    "test_file_names": [
        "test_1.py",
        "conftest.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Datalad installation attempts...\nVerifying installation...\n❌ Verification failed\nPython 3.9 installation failed, trying Python 3.7...\nVerifying installation...\nDatalad version: 0.11.4.dev87\n✅ Installation successful!\nSuccessfully installed Datalad using Python 3.7\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 25 packages in 141ms\nInstalled 25 packages in 4.59s\n + coverage==7.6.10\n + docopt==0.6.2\n + exceptiongroup==1.2.2\n + grabbit==0.2.6\n + importlib-resources==6.4.5\n + iniconfig==2.0.0\n + nibabel==5.3.2\n + num2words==0.5.14\n + numpy==2.0.2\n + packaging==24.2\n + pandas==2.2.3\n + patsy==1.0.1\n + pluggy==1.5.0\n + pybids==0.6.5\n + pytest==8.3.4\n + pytest-cov==6.0.0\n + python-dateutil==2.9.0.post0\n + pytz==2024.2\n + scipy==1.13.1\n + setuptools==75.6.0\n + six==1.17.0\n + tomli==2.2.1\n + typing-extensions==4.12.2\n + tzdata==2024.2\n + zipp==3.21.0\nerror: The build backend returned an error\n  Caused by: Call to `setuptools.build_meta:__legacy__.build_editable` failed (exit status: 1)\n\n[stderr]\nTraceback (most recent call last):\n  File \"<string>\", line 14, in <module>\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmp2HOxc6/lib/python3.9/site-packages/setuptools/build_meta.py\", line 483, in get_requires_for_build_editable\n    return self.get_requires_for_build_wheel(config_settings)\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmp2HOxc6/lib/python3.9/site-packages/setuptools/build_meta.py\", line 334, in get_requires_for_build_wheel\n    return self._get_build_requires(config_settings, requirements=[])\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmp2HOxc6/lib/python3.9/site-packages/setuptools/build_meta.py\", line 304, in _get_build_requires\n    self.run_setup()\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmp2HOxc6/lib/python3.9/site-packages/setuptools/build_meta.py\", line 522, in run_setup\n    super().run_setup(setup_script=setup_script)\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmp2HOxc6/lib/python3.9/site-packages/setuptools/build_meta.py\", line 320, in run_setup\n    exec(code, locals())\n  File \"<string>\", line 51, in <module>\nAttributeError: module 'platform' has no attribute 'dist'\n\nhint: This usually indicates a problem with the package or the build environment.\nerror: The build backend returned an error\n  Caused by: Call to `setuptools.build_meta:__legacy__.build_editable` failed (exit status: 1)\n\n[stderr]\nTraceback (most recent call last):\n  File \"<string>\", line 14, in <module>\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmpnFryBz/lib/python3.9/site-packages/setuptools/build_meta.py\", line 483, in get_requires_for_build_editable\n    return self.get_requires_for_build_wheel(config_settings)\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmpnFryBz/lib/python3.9/site-packages/setuptools/build_meta.py\", line 334, in get_requires_for_build_wheel\n    return self._get_build_requires(config_settings, requirements=[])\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmpnFryBz/lib/python3.9/site-packages/setuptools/build_meta.py\", line 304, in _get_build_requires\n    self.run_setup()\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmpnFryBz/lib/python3.9/site-packages/setuptools/build_meta.py\", line 522, in run_setup\n    super().run_setup(setup_script=setup_script)\n  File \"/home/gcpuser/.cache/uv/builds-v0/.tmpnFryBz/lib/python3.9/site-packages/setuptools/build_meta.py\", line 320, in run_setup\n    exec(code, locals())\n  File \"<string>\", line 51, in <module>\nAttributeError: module 'platform' has no attribute 'dist'\n\nhint: This usually indicates a problem with the package or the build environment.\nTraceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/datalad_ae60a378de415bbd1039eef3719ff04b4266a4af/datalad/__init__.py\", line 43, in <module>\n    from datalad.cmd import GitRunner\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/datalad_ae60a378de415bbd1039eef3719ff04b4266a4af/datalad/cmd.py\", line 32, in <module>\n    from .support import path as op\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/datalad_ae60a378de415bbd1039eef3719ff04b4266a4af/datalad/support/path.py\", line 21, in <module>\n    from ..utils import (\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/datalad_ae60a378de415bbd1039eef3719ff04b4266a4af/datalad/utils.py\", line 26, in <module>\n    import wrapt\nModuleNotFoundError: No module named 'wrapt'\nUsing CPython 3.7.9\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 26 packages in 274ms\nInstalled 26 packages in 2.30s\n + bids==0.0\n + coverage==7.2.7\n + docopt==0.6.2\n + exceptiongroup==1.2.2\n + fasteners==0.19\n + grabbit==0.2.6\n + importlib-metadata==6.7.0\n + iniconfig==2.0.0\n + nibabel==4.0.2\n + num2words==0.5.14\n + numpy==1.21.6\n + packaging==24.0\n + pandas==1.3.5\n + patsy==1.0.1\n + pluggy==1.2.0\n + pybids==0.6.5\n + pytest==7.4.4\n + pytest-cov==4.1.0\n + python-dateutil==2.9.0.post0\n + pytz==2024.2\n + scipy==1.7.3\n + setuptools==68.0.0\n + six==1.17.0\n + tomli==2.0.1\n + typing-extensions==4.7.1\n + zipp==3.15.0\nResolved 60 packages in 1.23s\nPrepared 1 package in 1.43s\nInstalled 53 packages in 17ms\n + appdirs==1.4.4\n + beautifulsoup4==4.12.3\n + boto==2.49.0\n + certifi==2024.12.14\n + cffi==1.15.1\n + chardet==5.2.0\n + charset-normalizer==3.4.1\n + citeproc-py==0.6.0\n + cryptography==44.0.0\n + datalad==0.11.4 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/datalad_ae60a378de415bbd1039eef3719ff04b4266a4af)\n + deprecated==1.2.15\n + duecredit==0.9.3\n + exifread==3.0.0\n + gitdb==4.0.12\n + gitpython==3.1.44\n + httpretty==1.1.4\n + humanize==4.6.0\n + idna==3.10\n + importlib-resources==5.12.0\n + iso8601==2.1.0\n + jaraco-classes==3.2.3\n + jeepney==0.8.0\n + jsmin==3.0.1\n + keyring==24.1.1\n + keyrings-alt==4.2.0\n + lxml==5.3.0\n + mock==5.1.0\n + more-itertools==9.1.0\n + msgpack==1.0.5\n + multidict==6.0.5\n + mutagen==1.47.0\n + nose==1.3.7\n + patool==1.12\n + pillow==9.5.0\n + pycparser==2.21\n + pygithub==2.3.0\n + pyjwt==2.8.0\n + pynacl==1.5.0\n + pyperclip==1.9.0\n + python-xmp-toolkit==2.0.2\n + pyyaml==6.0.1\n + requests==2.31.0\n + requests-ftp==0.3.1\n + secretstorage==3.3.3\n + simplejson==3.19.3\n + smmap==5.0.2\n + soupsieve==2.4.1\n + tqdm==4.67.1\n + urllib3==2.0.7\n + vcrpy==4.3.0\n + whoosh==2.7.4\n + wrapt==1.16.0\n + yarl==1.9.4\nResolved 94 packages in 221ms\nInstalled 31 packages in 57ms\n + alabaster==0.7.13\n + asv==0.6.4\n + asv-runner==0.2.1\n + babel==2.14.0\n + build==1.1.1\n + distlib==0.3.9\n + docutils==0.19\n + filelock==3.12.2\n + imagesize==1.4.1\n + jinja2==3.1.5\n + json5==0.9.16\n + markupsafe==2.1.5\n + nose-timer==1.0.1\n + platformdirs==4.0.0\n + psutil==6.1.1\n + pygments==2.17.2\n + pympler==1.1\n + pypandoc==1.14\n + pyproject-hooks==1.2.0\n + snowballstemmer==2.2.0\n + sphinx==5.3.0\n + sphinx-rtd-theme==2.0.0\n + sphinxcontrib-applehelp==1.0.2\n + sphinxcontrib-devhelp==1.0.2\n + sphinxcontrib-htmlhelp==2.0.0\n + sphinxcontrib-jquery==4.1\n + sphinxcontrib-jsmath==1.0.1\n + sphinxcontrib-qthelp==1.0.3\n + sphinxcontrib-serializinghtml==1.1.5\n + tabulate==0.9.0\n + virtualenv==20.26.6\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/datalad_ae60a378de415bbd1039eef3719ff04b4266a4af\nplugins: cov-4.1.0\ncollected 4 items\n\nr2e_tests/test_1.py ....                                                 [100%]\n\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_color_enabled\nPASSED r2e_tests/test_1.py::test_format_msg\nPASSED r2e_tests/test_1.py::test_color_word\nPASSED r2e_tests/test_1.py::test_color_status\n============================== 4 passed in 0.78s ===============================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/datalad_ae60a378de415bbd1039eef3719ff04b4266a4af\nplugins: cov-4.1.0\ncollected 4 items\n\nr2e_tests/test_1.py F...                                                 [100%]\n\n=================================== FAILURES ===================================\n______________________________ test_color_enabled ______________________________\n\n    def test_color_enabled():\n        # In the absence of NO_COLOR, follow ui.color, or ui.is_interactive if 'auto'\n        with patch.dict(os.environ), \\\n             patch('datalad.support.ansi_colors.ui'):\n            os.environ.pop('NO_COLOR', None)\n            for is_interactive in (True, False):\n                colors.ui.is_interactive = is_interactive\n                with patch_config({'datalad.ui.color': 'off'}):\n                    assert_equal(colors.color_enabled(), False)\n                with patch_config({'datalad.ui.color': 'on'}):\n>                   assert_equal(colors.color_enabled(), True)\n\nr2e_tests/test_1.py:29: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n../../../../.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib/python3.7/unittest/case.py:852: in assertEqual\n    assertion_func(first, second, msg=msg)\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <nose.tools.trivial.Dummy testMethod=nop>, first = False, second = True\nmsg = 'False != True'\n\n    def _baseAssertEqual(self, first, second, msg=None):\n        \"\"\"The default assertEqual implementation, not type specific.\"\"\"\n        if not first == second:\n            standardMsg = '%s != %s' % _common_shorten_repr(first, second)\n            msg = self._formatMessage(msg, standardMsg)\n>           raise self.failureException(msg)\nE           AssertionError: False != True\n\n../../../../.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib/python3.7/unittest/case.py:845: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_format_msg\nPASSED r2e_tests/test_1.py::test_color_word\nPASSED r2e_tests/test_1.py::test_color_status\nFAILED r2e_tests/test_1.py::test_color_enabled - AssertionError: False != True\n========================= 1 failed, 3 passed in 0.38s ==========================\n",
    "old_commit_res_stderr": ""
}
datalad/support/ansi_colors.py datalad/support/tests/test_ansi_colors.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `color_enabled` returns `False` instead of `True` when `datalad.ui.color` is set to `'on'` and terminal is interactive

**Description:**
When the configuration `datalad.ui.color` is set to `'on'` and the terminal is interactive, the `color_enabled` function incorrectly returns `False`. This prevents colored output from being enabled as expected, even when the environment is correctly configured for color support.

**Example Code:**
```python
with patch.dict(os.environ, {}):
    colors.ui.is_interactive = True
    with patch_config({'datalad.ui.color': 'on'}):
        enabled = colors.color_enabled()
        # Expected: enabled is True
        # Actual: enabled is False
```

**Expected Behavior:**
The `color_enabled()` function should return `True` when `datalad.ui.color` is set to `'on'` and the terminal is detected as interactive. This ensures that colored output is enabled for the user.

**Actual Behavior:**
Instead of returning `True`, the `color_enabled()` function returns `False`, disabling colored output despite the correct configuration and interactive terminal state.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### datalad/support/ansi_colors.py
# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 noet:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
#   See COPYING file distributed along with the datalad package for the
#   copyright and license terms.
#
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Definitions for ansi colors etc"""

import os
from .. import cfg
from ..ui import ui

BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)
BOLD = 1
UNDERLINE = 4

RESET_SEQ = "\033[0m"
COLOR_SEQ = "\033[1;%dm"
BOLD_SEQ = "\033[1m"

LOG_LEVEL_COLORS = {
    'WARNING': YELLOW,
    'INFO': None,
    'DEBUG': BLUE,
    'CRITICAL': YELLOW,
    'ERROR': RED
}

RESULT_STATUS_COLORS = {
    'ok': GREEN,
    'notneeded': GREEN,
    'impossible': YELLOW,
    'error': RED
}

# Aliases for uniform presentation

DATASET = UNDERLINE
FIELD = BOLD


def color_enabled():
    """Check for whether color output is enabled

    Color is only enabled if the terminal is interactive.
    If the datalad.ui.color configuration setting is 'on' or 'off', then
    respect that.
    If the datalad.ui.color setting is 'auto' (default), then color is
    enabled unless the environment variable NO_COLOR is defined.

    Returns
    -------
    bool
    """
    if not ui.is_interactive:
        return False

    ui_color = cfg.obtain('datalad.ui.color')
    if ui_color == 'off':
        return False

    return ui_color == 'on' or os.getenv('NO_COLOR') is None


def format_msg(fmt, use_color=False):
    """Replace $RESET and $BOLD with corresponding ANSI entries"""
    if color_enabled() and use_color:
        return fmt.replace("$RESET", RESET_SEQ).replace("$BOLD", BOLD_SEQ)
    else:
        return fmt.replace("$RESET", "").replace("$BOLD", "")


def color_word(s, color, force=False):
    """Color `s` with `color`.

    Parameters
    ----------
    s : string
    color : int
        Code for color. If the value evaluates to false, the string will not be
        colored.
    force : boolean, optional
        Color string even when non-interactive session is detected.

    Returns
    -------
    str
    """
    if color and (force or color_enabled()):
        return "%s%s%s" % (COLOR_SEQ % color, s, RESET_SEQ)
    return s


def color_status(status):
    return color_word(status, RESULT_STATUS_COLORS.get(status))

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** `color_enabled` returns `False` instead of `True` when `datalad.ui.color` is set to `'on'` and terminal is interactive

**Description:**
When the configuration `datalad.ui.color` is set to `'on'` and the terminal is interactive, the `color_enabled` function incorrectly returns `False`. This prevents colored output from being enabled as expected, even when the environment is correctly configured for color support.

**Example Code:**
```python
with patch.dict(os.environ, {}):
    colors.ui.is_interactive = True
    with patch_config({'datalad.ui.color': 'on'}):
        enabled = colors.color_enabled()
        # Expected: enabled is True
        # Actual: enabled is False
```

**Expected Behavior:**
The `color_enabled()` function should return `True` when `datalad.ui.color` is set to `'on'` and the terminal is detected as interactive. This ensures that colored output is enabled for the user.

**Actual Behavior:**
Instead of returning `True`, the `color_enabled()` function returns `False`, disabling colored output despite the correct configuration and interactive terminal state.

[/ISSUE]
{
    "test_color_enabled": "PASSED",
    "test_format_msg": "PASSED",
    "test_color_word": "PASSED",
    "test_color_status": "PASSED"
}
diff --git a/datalad/support/ansi_colors.py b/datalad/support/ansi_colors.py
index eae5e691a..2be222611 100644
--- a/datalad/support/ansi_colors.py
+++ b/datalad/support/ansi_colors.py
@@ -44,24 +44,19 @@ FIELD = BOLD
 def color_enabled():
     """Check for whether color output is enabled
 
-    Color is only enabled if the terminal is interactive.
-    If the datalad.ui.color configuration setting is 'on' or 'off', then
-    respect that.
-    If the datalad.ui.color setting is 'auto' (default), then color is
-    enabled unless the environment variable NO_COLOR is defined.
+    If the configuration value ``datalad.ui.color`` is ``'on'`` or ``'off'``,
+    that takes precedence.
+    If ``datalad.ui.color`` is ``'auto'``, and the environment variable
+    ``NO_COLOR`` is defined (see https://no-color.org), then color is disabled.
+    Otherwise, enable colors if a TTY is detected by ``datalad.ui.ui.is_interactive``.
 
     Returns
     -------
     bool
     """
-    if not ui.is_interactive:
-        return False
-
     ui_color = cfg.obtain('datalad.ui.color')
-    if ui_color == 'off':
-        return False
-
-    return ui_color == 'on' or os.getenv('NO_COLOR') is None
+    return (ui_color == 'on' or
+            ui_color == 'auto' and os.getenv('NO_COLOR') is None and ui.is_interactive)
 
 
 def format_msg(fmt, use_color=False):

{"datalad/support/ansi_colors.py": "# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n# ex: set sts=4 ts=4 sw=4 noet:\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n#\n#   See COPYING file distributed along with the datalad package for the\n#   copyright and license terms.\n#\n# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n\"\"\"Definitions for ansi colors etc\"\"\"\n\nimport os\nfrom .. import cfg\nfrom ..ui import ui\n\nBLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)\nBOLD = 1\nUNDERLINE = 4\n\nRESET_SEQ = \"\\033[0m\"\nCOLOR_SEQ = \"\\033[1;%dm\"\nBOLD_SEQ = \"\\033[1m\"\n\nLOG_LEVEL_COLORS = {\n    'WARNING': YELLOW,\n    'INFO': None,\n    'DEBUG': BLUE,\n    'CRITICAL': YELLOW,\n    'ERROR': RED\n}\n\nRESULT_STATUS_COLORS = {\n    'ok': GREEN,\n    'notneeded': GREEN,\n    'impossible': YELLOW,\n    'error': RED\n}\n\n# Aliases for uniform presentation\n\nDATASET = UNDERLINE\nFIELD = BOLD\n\n\ndef color_enabled():\n    \"\"\"Check for whether color output is enabled\n\n    Color is only enabled if the terminal is interactive.\n    If the datalad.ui.color configuration setting is 'on' or 'off', then\n    respect that.\n    If the datalad.ui.color setting is 'auto' (default), then color is\n    enabled unless the environment variable NO_COLOR is defined.\n\n    Returns\n    -------\n    bool\n    \"\"\"\n    if not ui.is_interactive:\n        return False\n\n    ui_color = cfg.obtain('datalad.ui.color')\n    if ui_color == 'off':\n        return False\n\n    return ui_color == 'on' or os.getenv('NO_COLOR') is None\n\n\ndef format_msg(fmt, use_color=False):\n    \"\"\"Replace $RESET and $BOLD with corresponding ANSI entries\"\"\"\n    if color_enabled() and use_color:\n        return fmt.replace(\"$RESET\", RESET_SEQ).replace(\"$BOLD\", BOLD_SEQ)\n    else:\n        return fmt.replace(\"$RESET\", \"\").replace(\"$BOLD\", \"\")\n\n\ndef color_word(s, color, force=False):\n    \"\"\"Color `s` with `color`.\n\n    Parameters\n    ----------\n    s : string\n    color : int\n        Code for color. If the value evaluates to false, the string will not be\n        colored.\n    force : boolean, optional\n        Color string even when non-interactive session is detected.\n\n    Returns\n    -------\n    str\n    \"\"\"\n    if color and (force or color_enabled()):\n        return \"%s%s%s\" % (COLOR_SEQ % color, s, RESET_SEQ)\n    return s\n\n\ndef color_status(status):\n    return color_word(status, RESULT_STATUS_COLORS.get(status))\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `color_enabled` returns `False` instead of `True` when `datalad.ui.color` is set to `'on'` and terminal is interactive

**Description:**
When the configuration `datalad.ui.color` is set to `'on'` and the terminal is interactive, the `color_enabled` function incorrectly returns `False`. This prevents colored output from being enabled as expected, even when the environment is correctly configured for color support.

**Example Code:**
```python
with patch.dict(os.environ, {}):
    colors.ui.is_interactive = True
    with patch_config({'datalad.ui.color': 'on'}):
        enabled = colors.color_enabled()
        # Expected: enabled is True
        # Actual: enabled is False
```

**Expected Behavior:**
The `color_enabled()` function should return `True` when `datalad.ui.color` is set to `'on'` and the terminal is detected as interactive. This ensures that colored output is enabled for the user.

**Actual Behavior:**
Instead of returning `True`, the `color_enabled()` function returns `False`, disabling colored output despite the correct configuration and interactive terminal state.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### datalad/support/ansi_colors.py
# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 noet:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
#   See COPYING file distributed along with the datalad package for the
#   copyright and license terms.
#
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Definitions for ansi colors etc"""

import os
from .. import cfg
from ..ui import ui

BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)
BOLD = 1
UNDERLINE = 4

RESET_SEQ = "\033[0m"
COLOR_SEQ = "\033[1;%dm"
BOLD_SEQ = "\033[1m"

LOG_LEVEL_COLORS = {
    'WARNING': YELLOW,
    'INFO': None,
    'DEBUG': BLUE,
    'CRITICAL': YELLOW,
    'ERROR': RED
}

RESULT_STATUS_COLORS = {
    'ok': GREEN,
    'notneeded': GREEN,
    'impossible': YELLOW,
    'error': RED
}

# Aliases for uniform presentation

DATASET = UNDERLINE
FIELD = BOLD


def color_enabled():
    """Check for whether color output is enabled

    Color is only enabled if the terminal is interactive.
    If the datalad.ui.color configuration setting is 'on' or 'off', then
    respect that.
    If the datalad.ui.color setting is 'auto' (default), then color is
    enabled unless the environment variable NO_COLOR is defined.

    Returns
    -------
    bool
    """
    if not ui.is_interactive:
        return False

    ui_color = cfg.obtain('datalad.ui.color')
    if ui_color == 'off':
        return False

    return ui_color == 'on' or os.getenv('NO_COLOR') is None


def format_msg(fmt, use_color=False):
    """Replace $RESET and $BOLD with corresponding ANSI entries"""
    if color_enabled() and use_color:
        return fmt.replace("$RESET", RESET_SEQ).replace("$BOLD", BOLD_SEQ)
    else:
        return fmt.replace("$RESET", "").replace("$BOLD", "")


def color_word(s, color, force=False):
    """Color `s` with `color`.

    Parameters
    ----------
    s : string
    color : int
        Code for color. If the value evaluates to false, the string will not be
        colored.
    force : boolean, optional
        Color string even when non-interactive session is detected.

    Returns
    -------
    str
    """
    if color and (force or color_enabled()):
        return "%s%s%s" % (COLOR_SEQ % color, s, RESET_SEQ)
    return s


def color_status(status):
    return color_word(status, RESULT_STATUS_COLORS.get(status))

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user