From 55e90b7bdfd075f25e6371dd4e257b9e6204cc66 Mon Sep 17 00:00:00 2001 From: "Mr. Outis" Date: Tue, 31 Dec 2019 23:42:40 -0600 Subject: [PATCH] py3: ignore_file_not_found -> contextlib.suppress --- dvc/remote/ssh/connection.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dvc/remote/ssh/connection.py b/dvc/remote/ssh/connection.py index abc131173..d8461356f 100644 --- a/dvc/remote/ssh/connection.py +++ b/dvc/remote/ssh/connection.py @@ -3,6 +3,7 @@ import logging import os import posixpath import stat +from contextlib import suppress from funcy import cached_property @@ -12,7 +13,6 @@ except ImportError: paramiko = None from dvc.utils import tmp_fname -from dvc.utils.compat import ignore_file_not_found from dvc.progress import Tqdm from dvc.exceptions import DvcException from dvc.remote.base import RemoteCmdError @@ -60,13 +60,13 @@ class SSHConnection: self._ssh.close() def st_mode(self, path): - with ignore_file_not_found(): + with suppress(FileNotFoundError): return self.sftp.lstat(path).st_mode return 0 def getsize(self, path): - with ignore_file_not_found(): + with suppress(FileNotFoundError): return self.sftp.lstat(path).st_size return 0 @@ -153,22 +153,22 @@ class SSHConnection: yield posixpath.join(root, fname) def _remove_file(self, path): - with ignore_file_not_found(): + with suppress(FileNotFoundError): self.sftp.remove(path) def _remove_dir(self, path): for root, dirs, files in self.walk(path, topdown=False): for fname in files: path = posixpath.join(root, fname) - with ignore_file_not_found(): + with suppress(FileNotFoundError): self._remove_file(path) for dname in dirs: path = posixpath.join(root, dname) - with ignore_file_not_found(): + with suppress(FileNotFoundError): self.sftp.rmdir(dname) - with ignore_file_not_found(): + with suppress(FileNotFoundError): self.sftp.rmdir(path) def remove(self, path):