Skip to content

Commit e6813e4

Browse files
author
Jussi Kukkonen
authored
Merge pull request #1495 from avelichka/develop
Use %-style formatting in logging
2 parents 267ce83 + db04c71 commit e6813e4

1 file changed

Lines changed: 19 additions & 23 deletions

File tree

tuf/ngclient/updater.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ def _preorder_depth_first_walk(self, target_filepath) -> Dict:
327327
self._load_targets(role_name, parent_role)
328328
# Skip any visited current role to prevent cycles.
329329
if (role_name, parent_role) in visited_role_names:
330-
msg = f"Skipping visited current role {role_name}"
331-
logger.debug(msg)
330+
logger.debug("Skipping visited current role %s", role_name)
332331
continue
333332

334333
# The metadata for 'role_name' must be downloaded/updated before
@@ -357,24 +356,22 @@ def _preorder_depth_first_walk(self, target_filepath) -> Dict:
357356
)
358357

359358
if child_role.terminating and child_role_name is not None:
360-
msg = (
361-
f"Adding child role {child_role_name}.\n",
359+
logger.debug(
360+
"Adding child role %s.\n"
362361
"Not backtracking to other roles.",
362+
child_role_name,
363363
)
364-
logger.debug(msg)
365364
role_names = []
366365
child_roles_to_visit.append(
367366
(child_role_name, role_name)
368367
)
369368
break
370369

371370
if child_role_name is None:
372-
msg = f"Skipping child role {child_role_name}"
373-
logger.debug(msg)
371+
logger.debug("Skipping child role %s", child_role_name)
374372

375373
else:
376-
msg = f"Adding child role {child_role_name}"
377-
logger.debug(msg)
374+
logger.debug("Adding child role %s", child_role_name)
378375
child_roles_to_visit.append(
379376
(child_role_name, role_name)
380377
)
@@ -386,19 +383,19 @@ def _preorder_depth_first_walk(self, target_filepath) -> Dict:
386383
role_names.extend(child_roles_to_visit)
387384

388385
else:
389-
msg = f"Found target in current role {role_name}"
390-
logger.debug(msg)
386+
logger.debug("Found target in current role %s", role_name)
391387

392388
if (
393389
target is None
394390
and number_of_delegations == 0
395391
and len(role_names) > 0
396392
):
397-
msg = (
398-
f"{len(role_names)} roles left to visit, but allowed to ",
399-
f"visit at most {self.config.max_delegations} delegations.",
393+
logger.debug(
394+
"%d roles left to visit, but allowed to "
395+
"visit at most %d delegations.",
396+
len(role_names),
397+
self.config.max_delegations,
400398
)
401-
logger.debug(msg)
402399

403400
return {"filepath": target_filepath, "fileinfo": target}
404401

@@ -471,19 +468,18 @@ def _visit_child_role(child_role: Dict, target_filepath: str) -> str:
471468
target_filepath.lstrip(os.sep), child_role_path.lstrip(os.sep)
472469
):
473470
logger.debug(
474-
"Child role "
475-
+ repr(child_role_name)
476-
+ " is allowed to sign for "
477-
+ repr(target_filepath)
471+
"Child role %s is allowed to sign for %s",
472+
repr(child_role_name),
473+
repr(target_filepath),
478474
)
479475

480476
return child_role_name
481477

482478
logger.debug(
483-
"The given target path "
484-
+ repr(target_filepath)
485-
+ " does not match the trusted path or glob pattern: "
486-
+ repr(child_role_path)
479+
"The given target path %s "
480+
"does not match the trusted path or glob pattern: %s",
481+
repr(target_filepath),
482+
repr(child_role_path),
487483
)
488484
continue
489485

0 commit comments

Comments
 (0)