Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/pyquickhelper/helpgen/sphinxm_convert_doc_sphinx_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ def _init_env(self, freshenv):
self.env.setup(self)
self.info('done')
except Exception as err:
self.info(f'failed: {err}')
self.info('failed: %r', err)
self._init_env(freshenv=True)
elif self.env is None: # pragma: no cover
self.env = _CustomBuildEnvironment(self)
Expand Down Expand Up @@ -1382,17 +1382,14 @@ def add_directive(self, name, obj, content=None, arguments=None, # pylint: disa
def run(self):
"""Run the plot directive."""
logger = getLogger("MockSphinxApp")
logger.info(
f'[MockSphinxApp] PlotDirective: {self.content}')
logger.info('[MockSphinxApp] PlotDirective: %r', self.content)
try:
res = old_run(self)
logger.info(
'[MockSphinxApp] PlotDirective ok')
logger.info('[MockSphinxApp] PlotDirective ok')
return res
except OSError as e: # pragma: no cover
logger = getLogger("MockSphinxApp")
logger.info(
f'[MockSphinxApp] PlotDirective failed: {e}')
logger.info('[MockSphinxApp] PlotDirective failed: %s', e)
return []

obj.run = run
Expand Down
11 changes: 4 additions & 7 deletions src/pyquickhelper/pycode/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,10 @@ def write_covlog(covs):
err = res.get("err", "")
if len(err) > 0: # pragma: no cover
# Remove most of the Sphinx warnings (sphinx < 1.8)
lines = err.split("\n")
lines = [
_ for _ in lines if _ and (
"is already registered, it will be overridden" not in _ and
"has to be local relative or absolute path to image" not in _)]
err = "\n".join(lines)
if len(err) > 0:
fLOG("[main_wrapper_tests] EXCEPTION BEGIN")
fLOG(err)
fLOG("[main_wrapper_tests] EXCEPTION END")
if len(err) > 10000:
raise TestWrappedException(err) # pragma: no cover

datetime_end = datetime.now()
Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/sphinxext/_sphinx_common_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def base_visit_image(self, node, image_dest=None):
except InternetException as e: # pragma: no cover
logger = logging.getLogger("image")
logger.warning(
"[image] unable to get content for url '{0}' due to '{1}'"
"".format(atts['src'], e))
"[image] unable to get content for url %r due to %r",
atts['src'], e)
this = os.path.abspath(
os.path.dirname(__file__))
full = os.path.join(
Expand Down
21 changes: 10 additions & 11 deletions src/pyquickhelper/sphinxext/sphinx_autosignature.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ def keep_logging(*els):
if logging_function:
logging_function(mes) # pragma: no cover
if lineno is not None:
logger.warning(
f' File "{source}", line {lineno}')
logger.warning(' File "%s", line %r', source, lineno)
obj = None
kind = None
if opt_syspath:
Expand All @@ -175,8 +174,8 @@ def keep_logging(*els):
if opt_members is not None and kind != "class": # pragma: no cover
logger = logging.getLogger("autosignature")
logger.warning(
"[autosignature] option members is specified but '{0}' "
"is not a class (kind='{1}').".format(object_name, kind))
"[autosignature] option members is specified but %r "
"is not a class (kind=%r).", object_name, kind)
obj = None

# build node
Expand All @@ -187,8 +186,8 @@ def keep_logging(*els):
if opt_path == 'import':
if obj is None:
logger = logging.getLogger("autosignature")
logger.warning(
f"[autosignature] object '{object_name}' cannot be imported.")
logger.warning("[autosignature] object %r cannot be imported.",
object_name)
anchor = object_name
elif kind == "staticmethod":
cl, fu = object_name.split(".")[-2:]
Expand All @@ -205,8 +204,8 @@ def keep_logging(*els):
else: # pragma: no cover
logger = logging.getLogger("autosignature")
logger.warning(
"[autosignature] options path is '{0}', it should be in "
"(import, name, full) for object '{1}'.".format(opt_path, object_name))
"[autosignature] options path is %r, it should be in "
"(import, name, full) for object %r.", opt_path, object_name)
anchor = object_name

if obj is None:
Expand Down Expand Up @@ -334,7 +333,7 @@ def build_members(self, obj, members, object_name, annotation, summary):
logger = logging.getLogger("autosignature")
logger.warning(
"[autosignature](2) unable to get signature of "
"'{0}.{1} - {2}'.".format(object_name, name, str(e).replace("\n", "\\n")))
"'%s.%s - %s'.", object_name, name, str(e).replace("\n", "\\n"))
signature = None
except ValueError: # pragma: no cover
signature = None
Expand All @@ -355,8 +354,8 @@ def build_members(self, obj, members, object_name, annotation, summary):
doc = value.__doc__
if doc is None: # pragma: no cover
logger = logging.getLogger("autosignature")
logger.warning(
f"[autosignature] docstring empty for '{object_name}.{name}'.")
logger.warning("[autosignature] docstring empty for '%s.%s'.",
object_name, name)
else:
docstring = self.build_summary(doc)
lines = "\n".join(
Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/sphinxext/sphinx_bigger_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def depart_bigger_node(self, node):
depart bigger_node for format other than html
"""
logger = getLogger("bigger")
logger.warning("[depart_bigger_node] output only available for HTML not for '{0}'".format(
type(self)))
logger.warning(
"[depart_bigger_node] output only available for HTML not for %r", type(self))


def setup(app):
Expand Down
2 changes: 1 addition & 1 deletion src/pyquickhelper/sphinxext/sphinx_blog_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def fill_node(self, node, env, tag, p, language_code, targetnode, sharepost):
from sphinx.util import logging
logger = logging.getLogger("blogpost")
logger.warning(
f"[blogpost] unable to parse '{title}' - {e}")
"[blogpost] unable to parse %r - %s", title, e)
raise e

# final
Expand Down
30 changes: 15 additions & 15 deletions src/pyquickhelper/sphinxext/sphinx_cmdref_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ def run(self):
out = "--SCRIPT--{}\n--OUT--\n{}\n--ERR--\n{}\n--PATH--\n{}".format(
name, out, err, path)
logger = logging.getLogger("CmdRef")
logger.warning(f"[CmdRef] cmd failed '{name}'")
logger.warning("[CmdRef] cmd failed %r", name)
elif out in (None, ''):
out = f"--SCRIPT--{name}\n--EMPTY OUTPUT--\n--PATH--\n{path}"
logger = logging.getLogger("CmdRef")
logger.warning(f"[CmdRef] cmd empty '{name}'")
logger.warning("[CmdRef] cmd empty %r", name)
content = "python " + name
cont += nodes.paragraph('<<<', '<<<')
pout = nodes.literal_block(content, content)
Expand All @@ -122,20 +122,22 @@ def run(self):
if ":" not in name:
logger = logging.getLogger("CmdRef")
logger.warning(
f"[CmdRef] cmd '{name}' should contain ':': <full_function_name>:<cmd_name> as specified in the setup.")
"[CmdRef] cmd %r should contain ':': "
"<full_function_name>:<cmd_name> as specified in the setup.",
name)
if lineno is not None:
logger.warning(
f' File "{source}", line {lineno}')
logger.warning(' File "%s", line %r', source, lineno)

# example: pyquickhelper.cli.pyq_sync_cli:pyq_sync
spl = name.strip("\r\n\t ").split(":")
if len(spl) != 2: # pragma: no cover
logger = logging.getLogger("CmdRef")
logger.warning(
f"[CmdRef] cmd(*= '{name}' should contain ':': <full_function_name>:<cmd_name> as specified in the setup.")
"[CmdRef] cmd(*= %r should contain ':': "
"<full_function_name>:<cmd_name> as specified in the setup.",
name)
if lineno is not None:
logger.warning(
f' File "{source}", line {lineno}')
logger.warning(' File "%s", line %r', source, lineno)

# rename the command line
if "=" in spl[0]:
Expand All @@ -154,11 +156,9 @@ def run(self):
obj, name = import_object(fullname, kind="function")
except ImportError: # pragma: no cover
logger = logging.getLogger("CmdRef")
logger.warning(
f"[CmdRef] unable to import '{fullname}'")
logger.warning("[CmdRef] unable to import %r", fullname)
if lineno is not None:
logger.warning(
f' File "{source}", line {lineno}')
logger.warning(' File "%s", line %r', source, lineno)
obj = None

if obj is not None:
Expand All @@ -177,13 +177,13 @@ def local_print(*li):
if len(content) == 0: # pragma: no cover
logger = logging.getLogger("CmdRef")
logger.warning(
f"[CmdRef] empty output for '{fullname}'")
"[CmdRef] empty output for %r", fullname)
if lineno is not None:
logger.warning(
f' File "{source}", line {lineno}')
' File "%s", line %r', source, lineno)
out = f"--SCRIPT--{name}\n--EMPTY OUTPUT--\n--PATH--\n{path}"
logger = logging.getLogger("CmdRef")
logger.warning(f"[CmdRef] cmd empty '{name}'")
logger.warning("[CmdRef] cmd empty %r", name)
else:
start = 'usage: ' + name_fct
if content.startswith(start):
Expand Down
25 changes: 13 additions & 12 deletions src/pyquickhelper/sphinxext/sphinx_docassert_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def check_typed_make_field(self, types, domain, items, env=None, parameters=None
function_name=None, docname=None, kind=None):
"""
Overwrites function
`make_field <https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py#L197>`_.
#L197>`_.
`make_field <https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py
Processes one argument of a function.

@param self from original function
Expand Down Expand Up @@ -54,13 +55,13 @@ def check_item(fieldarg, content, logger):
"local function"
if fieldarg not in check_params:
if function_name is not None:
logger.warning("[docassert] '{0}' has no parameter '{1}' (in '{2}').".format(
function_name, fieldarg, docname))
logger.warning("[docassert] %r has no parameter %r (in %r).",
function_name, fieldarg, docname)
else:
check_params[fieldarg] += 1
if check_params[fieldarg] > 1:
logger.warning("[docassert] '{1}' of '{0}' is duplicated (in '{2}').".format(
function_name, fieldarg, docname))
logger.warning("[docassert] %r of %r is duplicated (in %r).",
fieldarg, function_name, docname)

if isinstance(items, list):
for fieldarg, content in items:
Expand All @@ -74,8 +75,8 @@ def check_item(fieldarg, content, logger):
# Behavior should be improved.
pass
else:
logger.warning("[docassert] '{0}' has undocumented parameters '{1}' (in '{2}').".format(
function_name, ", ".join(nodoc), docname))
logger.warning("[docassert] %r has undocumented parameters %r (in %r).",
function_name, ", ".join(nodoc), docname)
else:
# Documentation related to the return.
pass
Expand Down Expand Up @@ -208,8 +209,8 @@ def override_transform(self, other_self, node):
else:
reasons = "unknown"
logger = logging.getLogger("docassert")
logger.warning(
f"[docassert] unable to import object '{docs}', reasons:\n{reasons}")
logger.warning("[docassert] unable to import object %r, reasons:\n%s",
docs, reasons)
myfunc = None

if myfunc is None:
Expand All @@ -222,7 +223,7 @@ def override_transform(self, other_self, node):
except (TypeError, ValueError):
logger = logging.getLogger("docassert")
logger.warning(
f"[docassert] unable to get signature of '{docs}'.")
"[docassert] unable to get signature of %r.", docs)
signature = None
parameters = None

Expand Down Expand Up @@ -253,7 +254,7 @@ def override_transform(self, other_self, node):
env = other_self.directive.state.document.settings.env
except AttributeError as e:
logger = logging.getLogger("docassert")
logger.warning(f"[docassert] {e}")
logger.warning("[docassert] %s", e)
env = None

docname = fieldbody.parent.source.split(':docstring')[0]
Expand All @@ -262,7 +263,7 @@ def override_transform(self, other_self, node):
if isinstance(entry, nodes.field):
logger = logging.getLogger("docassert")
logger.warning(
f"[docassert] unable to check [nodes.field] {entry}")
"[docassert] unable to check [nodes.field] %s", entry)
else:
fieldtype, content = entry
fieldtypes = types.get(fieldtype.name, {})
Expand Down
3 changes: 1 addition & 2 deletions src/pyquickhelper/sphinxext/sphinx_doctree_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def __init__(self, document, builder):

def log_unknown(self, type, node):
logger = logging.getLogger("DocTreeBuilder")
logger.warning(
f"[doctree] {type}({node}) unsupported formatting")
logger.warning("[doctree] %s(%s) unsupported formatting", type, node)

def wrap(self, text, width=STDINDENT):
self.wrapper.width = width
Expand Down
13 changes: 6 additions & 7 deletions src/pyquickhelper/sphinxext/sphinx_downloadlink_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def process_downloadlink_role(role, rawtext, text, lineno, inliner, options=None
node['anchor'] = anchor

logger = logging.getLogger("downloadlink")
logger.info(f"[downloadlink] node '{str(node)}'")
logger.info("[downloadlink] node %s", node)

return [node], []

Expand All @@ -123,7 +123,7 @@ def visit_downloadlink_node_html(self, node):
raise nodes.SkipNode

logger = logging.getLogger("downloadlink")
logger.info(f"[downloadlink] HTML '{str(node)}'")
logger.info("[downloadlink] HTML %s", node)

atts = {'class': 'reference'}

Expand Down Expand Up @@ -187,7 +187,7 @@ def visit_downloadlink_node_rst(self, node):
Converts node *downloadlink* into :epkg:`rst`.
"""
logger = logging.getLogger("downloadlink")
logger.info(f"[downloadlink] RST '{str(node)}'")
logger.info("[downloadlink] RST %s", node)

if node['format']:
self.add_text(":downloadlink:`{0} <{1}::{2}>`".format(
Expand Down Expand Up @@ -255,7 +255,7 @@ def process_doc(self, app, doctree):
app.env.docname, rel_filename)
if nb > 0:
logger = logging.getLogger("downloadlink")
logger.info(f"[downloadlink] processed {nb}")
logger.info("[downloadlink] processed %r", nb)


def copy_download_files(app, exc):
Expand Down Expand Up @@ -291,13 +291,12 @@ def to_relpath(f):
name = os.path.join(builder.srcdir, src)
try:
copyfile(name, dest)
logger.info(
f"[downloadlink] copy '{name}' to '{dest}'")
logger.info("[downloadlink] copy %r to %r", name, dest)
except FileNotFoundError:
mes = "Builder format '{0}'-'{3}', unable to copy file '{1}' into {2}'".format(
builder.format, name, dest, builder.__class__.__name__)
logger.warning(
f"[downloadlink] cannot copy '{name}' to '{dest}'")
"[downloadlink] cannot copy %r to %r", name, dest)


def setup(app):
Expand Down
Loading