Skip to content

Commit

Permalink
Move cli_level_to_log_level to redbot.core.cli to fix circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackenmen committed May 10, 2023
1 parent f1de0c4 commit d99efdf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
15 changes: 13 additions & 2 deletions redbot/core/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import discord
from discord import __version__ as discord_version

from redbot.core.utils._internal_utils import cli_level_to_log_level
from red_commons.logging import VERBOSE, TRACE


# This needs to be an int enum to be used
Expand Down Expand Up @@ -324,3 +323,15 @@ def parse_cli_flags(args):
args.logging_level = cli_level_to_log_level(args.logging_level)

return args


def cli_level_to_log_level(level: int) -> int:
if level == 0:
log_level = logging.INFO
elif level == 1:
log_level = logging.DEBUG
elif level == 2:
log_level = VERBOSE
else:
log_level = TRACE
return log_level
14 changes: 0 additions & 14 deletions redbot/core/utils/_internal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from rapidfuzz import fuzz, process
from rich.progress import ProgressColumn
from rich.progress_bar import ProgressBar
from red_commons.logging import VERBOSE, TRACE

from redbot import VersionInfo
from redbot.core import _data_manager, data_manager
Expand All @@ -58,7 +57,6 @@
"fetch_latest_red_version_info",
"deprecated_removed",
"RichIndefiniteBarColumn",
"cli_level_to_log_level",
)

_T = TypeVar("_T")
Expand Down Expand Up @@ -359,15 +357,3 @@ def render(self, task):
total=task.total,
completed=task.completed,
)


def cli_level_to_log_level(level: int) -> int:
if level == 0:
log_level = logging.INFO
elif level == 1:
log_level = logging.DEBUG
elif level == 2:
log_level = VERBOSE
else:
log_level = TRACE
return log_level
3 changes: 1 addition & 2 deletions redbot/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

import click

from redbot.core._cli import confirm
from redbot.core._cli import cli_level_to_log_level, confirm
from redbot.core.utils._internal_utils import (
safe_delete,
create_backup as red_create_backup,
cli_level_to_log_level,
)
from redbot.core import config, data_manager, _data_manager, _drivers
from redbot.core._cli import ExitCodes
Expand Down

0 comments on commit d99efdf

Please sign in to comment.