Skip to content

Commit

Permalink
Switch uses of %r to %s with quotes to avoid escaped backslashes in l…
Browse files Browse the repository at this point in the history
…ogs, especially in windows paths
  • Loading branch information
alexmojaki authored and efiop committed Jul 4, 2022
1 parent 03b789e commit c59f935
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dvc/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ def _find_or_create_user_id():
return user_id

except LockError:
logger.debug("Failed to acquire %r", lockfile)
logger.debug("Failed to acquire '%s'", lockfile)
2 changes: 1 addition & 1 deletion dvc/commands/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _run(self, func, name):
try:
func(target)
except DvcException:
logger.exception("failed to %s %r", name, target)
logger.exception("failed to %s '%s'", name, target)
ret = 1
return ret

Expand Down
2 changes: 1 addition & 1 deletion dvc/commands/get_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run(self):
Repo.get_url(self.args.url, out=self.args.out, jobs=self.args.jobs)
return 0
except DvcException:
logger.exception("failed to get %r", self.args.url)
logger.exception("failed to get '%s'", self.args.url)
return 1


Expand Down
2 changes: 1 addition & 1 deletion dvc/commands/ls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def run(self):
ui.write("\n".join(entries))
return 0
except DvcException:
logger.exception("failed to list %r", self.args.url)
logger.exception("failed to list '%s'", self.args.url)
return 1


Expand Down
2 changes: 1 addition & 1 deletion dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _save_config(self, level, conf_dict):
filename = self.files[level]
fs = self._get_fs(level)

logger.debug("Writing %r.", filename)
logger.debug("Writing '%s'.", filename)

fs.makedirs(os.path.dirname(filename))

Expand Down
4 changes: 2 additions & 2 deletions dvc/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _spawn_posix(cmd, env):


def _spawn(cmd, env):
logger.debug("Trying to spawn %r", cmd)
logger.debug("Trying to spawn '%s'", cmd)

if os.name == "nt":
_spawn_windows(cmd, env)
Expand All @@ -90,7 +90,7 @@ def _spawn(cmd, env):
else:
raise NotImplementedError

logger.debug("Spawned %r", cmd)
logger.debug("Spawned '%s'", cmd)


def daemon(args):
Expand Down
2 changes: 1 addition & 1 deletion dvc/dvcfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def dump(self, stage, **kwargs):
assert not isinstance(stage, PipelineStage)
if self.verify:
check_dvcfile_path(self.repo, self.path)
logger.debug("Saving information to %r.", relpath(self.path))
logger.debug("Saving information to '%s'.", relpath(self.path))
dump_yaml(self.path, serialize.to_single_stage_file(stage))
self.repo.scm_context.track_file(self.relpath)

Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/experiments/executor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def _validate_remotes(cls, dvc: "Repo", git_remote: Optional[str]):

if git_remote == dvc.root_dir:
logger.warning(
"%r points to the current Git repo, experiment "
"'%s' points to the current Git repo, experiment "
"Git refs will not be pushed. But DVC cache and run cache "
"will automatically be pushed to the default DVC remote "
"(if any) on each experiment commit.",
Expand Down Expand Up @@ -604,7 +604,7 @@ def _auto_push(
except BaseException as exc: # pylint: disable=broad-except
logger.warning(
"Something went wrong while auto pushing experiment "
"to the remote %r: %s",
"to the remote '%s': %s",
git_remote,
exc,
)
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _pull(
force: bool,
) -> Mapping[SyncStatus, List["ExpRefInfo"]]:
refspec_list = [f"{exp_ref}:{exp_ref}" for exp_ref in refs]
logger.debug("git pull experiment %r -> '%s'", git_remote, refspec_list)
logger.debug("git pull experiment '%s' -> '%s'", git_remote, refspec_list)

with TqdmGit(desc="Fetching git refs") as pbar:
results: Mapping[str, SyncStatus] = repo.scm.fetch_refspecs(
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/experiments/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _push(
from ...scm import GitAuthError

refspec_list = [f"{exp_ref}:{exp_ref}" for exp_ref in refs]
logger.debug("git push experiment %r -> '%s'", refspec_list, git_remote)
logger.debug("git push experiment '%s' -> '%s'", refspec_list, git_remote)

with TqdmGit(desc="Pushing git refs") as pbar:
try:
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def gc(

removed = ogc(odb, used_obj_ids, jobs=jobs)
if not removed:
logger.info("No unused %r cache to remove.", scheme)
logger.info("No unused '%s' cache to remove.", scheme)

if not cloud:
return
Expand Down
6 changes: 3 additions & 3 deletions dvc/stage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _changed_deps(self):
status = dep.status()
if status:
logger.debug(
"Dependency '%s' of %s changed because it is %r.",
"Dependency '%s' of %s changed because it is '%s'.",
dep,
self,
status[str(dep)],
Expand All @@ -337,7 +337,7 @@ def changed_outs(self):
status = out.status()
if status:
logger.debug(
"Output '%s' of %s changed because it is %r.",
"Output '%s' of %s changed because it is '%s'.",
out,
self,
status[str(out)],
Expand Down Expand Up @@ -452,7 +452,7 @@ def compute_md5(self):
m = None
else:
m = compute_md5(self)
logger.debug("Computed %s md5: %r", self, m)
logger.debug("Computed %s md5: '%s'", self, m)
return m

def save(self, allow_missing=False):
Expand Down
2 changes: 1 addition & 1 deletion dvc/ui/pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def find_pager():

def pager(text: str) -> None:
_pager = find_pager()
logger.trace("Using pager: %r", _pager) # type: ignore[attr-defined]
logger.trace("Using pager: '%s'", _pager) # type: ignore[attr-defined]
make_pager(_pager)(text)


Expand Down
6 changes: 3 additions & 3 deletions dvc/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _is_outdated_file(self):
ctime = os.path.getmtime(self.updater_file)
outdated = time.time() - ctime >= self.TIMEOUT
if outdated:
logger.debug("%r is outdated", self.updater_file)
logger.debug("'%s' is outdated", self.updater_file)
return outdated

def _with_lock(self, func, action):
Expand All @@ -48,7 +48,7 @@ def _with_lock(self, func, action):
func()
except LockError:
logger.debug(
"Failed to acquire %r before %s updates",
"Failed to acquire '%s' before %s updates",
self.lock.lockfile,
action,
)
Expand Down Expand Up @@ -79,7 +79,7 @@ def _check(self):
latest = info["version"]
except Exception as exc: # pylint: disable=broad-except
logger.debug(
"%r is not a valid json: %s", self.updater_file, exc
"'%s' is not a valid json: %s", self.updater_file, exc
)
self.fetch()
return
Expand Down

0 comments on commit c59f935

Please sign in to comment.