Skip to content

Commit

Permalink
Refactor - Move _rest_format_section in message_handler_mix_in.py
Browse files Browse the repository at this point in the history
Following review see : #2654 (comment)
  • Loading branch information
Pierre-Sassoulas committed Mar 8, 2019
1 parent ca2ba2e commit 3de592c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
22 changes: 21 additions & 1 deletion pylint/utils/message_handler_mix_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,33 @@
from pylint.utils.message import Message
from pylint.utils.utils import (
WarningScope,
_rest_format_section,
_format_option_value,
build_message_def,
category_id,
get_module_and_frameid,
normalize_text,
)


def _rest_format_section(stream, section, options, doc=None):
"""format an options section using as ReST formatted output"""
if section:
print("%s\n%s" % (section, "'" * len(section)), file=stream)
if doc:
print(normalize_text(doc, line_len=79, indent=""), file=stream)
print(file=stream)
for optname, optdict, value in options:
help_opt = optdict.get("help")
print(":%s:" % optname, file=stream)
if help_opt:
help_opt = normalize_text(help_opt, line_len=79, indent=" ")
print(help_opt, file=stream)
if value:
value = str(_format_option_value(optdict, value))
print(file=stream)
print(" Default: ``%s``" % value.replace("`` ", "```` ``"), file=stream)


class MessagesHandlerMixIn:
"""a mix-in class containing all the messages related methods for the main
lint class
Expand Down
19 changes: 0 additions & 19 deletions pylint/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,22 +374,3 @@ def _ini_format(stream, options):


format_section = _ini_format_section


def _rest_format_section(stream, section, options, doc=None):
"""format an options section using as ReST formatted output"""
if section:
print("%s\n%s" % (section, "'" * len(section)), file=stream)
if doc:
print(normalize_text(doc, line_len=79, indent=""), file=stream)
print(file=stream)
for optname, optdict, value in options:
help_opt = optdict.get("help")
print(":%s:" % optname, file=stream)
if help_opt:
help_opt = normalize_text(help_opt, line_len=79, indent=" ")
print(help_opt, file=stream)
if value:
value = str(_format_option_value(optdict, value))
print(file=stream)
print(" Default: ``%s``" % value.replace("`` ", "```` ``"), file=stream)

0 comments on commit 3de592c

Please sign in to comment.