Skip to content

Commit 0f9f6fd

Browse files
Revert f-strings with logging.Logger.debug()
1 parent 247332b commit 0f9f6fd

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

fsspec/caching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def _fetch_block(self, block_number):
284284

285285
start = block_number * self.blocksize
286286
end = start + self.blocksize
287-
logger.info(f"BlockCache fetching block {block_number}")
287+
logger.info("BlockCache fetching block %d", block_number)
288288
block_contents = super()._fetch(start, end)
289289
return block_contents
290290

@@ -726,7 +726,7 @@ def _fetch_block(self, block_number, log_info="sync"):
726726

727727
start = block_number * self.blocksize
728728
end = start + self.blocksize
729-
logger.info(f"BlockCache fetching block ({log_info}) {block_number}")
729+
logger.info("BlockCache fetching block (%s) %d", log_info, block_number)
730730
block_contents = super()._fetch(start, end)
731731
return block_contents
732732

fsspec/gui.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ def _emit(self, sig, value=None):
153153
break
154154
except Exception as e:
155155
logger.exception(
156-
f"Exception ({e}) while executing callback for signal: {sig}"
156+
"Exception (%s) while executing callback for signal: %s"
157+
"" % (e, sig)
157158
)
158159

159160
def show(self, threads=False):

fsspec/implementations/cached.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ def _open(
283283
hash, blocks = detail["fn"], detail["blocks"]
284284
if blocks is True:
285285
# stored file is complete
286-
logger.debug(f"Opening local copy of {path}")
286+
logger.debug("Opening local copy of %s", path)
287287
return open(fn, mode)
288288
# TODO: action where partial file exists in read-only cache
289-
logger.debug(f"Opening partially cached copy of {path}")
289+
logger.debug("Opening partially cached copy of %s", path)
290290
else:
291291
hash = self._mapper(path)
292292
fn = os.path.join(self.storage[-1], hash)
@@ -299,7 +299,7 @@ def _open(
299299
"uid": self.fs.ukey(path),
300300
}
301301
self._metadata.update_file(path, detail)
302-
logger.debug(f"Creating local sparse file for {path}")
302+
logger.debug("Creating local sparse file for %s", path)
303303

304304
# call target filesystems open
305305
self._mkcache()
@@ -547,7 +547,7 @@ def _make_local_details(self, path):
547547
"uid": self.fs.ukey(path),
548548
}
549549
self._metadata.update_file(path, detail)
550-
logger.debug(f"Copying {path} to local cache")
550+
logger.debug("Copying %s to local cache", path)
551551
return fn
552552

553553
def cat(
@@ -604,7 +604,7 @@ def _open(self, path, mode="rb", **kwargs):
604604
detail, fn = detail
605605
_, blocks = detail["fn"], detail["blocks"]
606606
if blocks is True:
607-
logger.debug(f"Opening local copy of {path}")
607+
logger.debug("Opening local copy of %s", path)
608608

609609
# In order to support downstream filesystems to be able to
610610
# infer the compression from the original filename, like
@@ -700,7 +700,7 @@ def _open(self, path, mode="rb", **kwargs):
700700

701701
sha = self._mapper(path)
702702
fn = os.path.join(self.storage[-1], sha)
703-
logger.debug(f"Copying {path} to local cache")
703+
logger.debug("Copying %s to local cache", path)
704704
kwargs["mode"] = mode
705705

706706
self._mkcache()

fsspec/implementations/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ async def _file_info(url, session, size_policy="head", **kwargs):
831831
Default operation is to explicitly allow redirects and use encoding
832832
'identity' (no compression) to get the true size of the target.
833833
"""
834-
logger.debug(f"Retrieve file size for {url}")
834+
logger.debug("Retrieve file size for %s", url)
835835
kwargs = kwargs.copy()
836836
ar = kwargs.pop("allow_redirects", True)
837837
head = kwargs.get("headers", {}).copy()

fsspec/implementations/sftp.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, host, **ssh_kwargs):
4848
self._connect()
4949

5050
def _connect(self):
51-
logger.debug(f"Connecting to SFTP server {self.host}")
51+
logger.debug("Connecting to SFTP server %s", self.host)
5252
self.client = paramiko.SSHClient()
5353
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
5454
self.client.connect(self.host, **self.ssh_kwargs)
@@ -66,7 +66,7 @@ def _get_kwargs_from_urls(urlpath):
6666
return out
6767

6868
def mkdir(self, path, create_parents=False, mode=511):
69-
logger.debug(f"Creating folder {path}")
69+
logger.debug("Creating folder %s", path)
7070
if self.exists(path):
7171
raise FileExistsError(f"File exists: {path}")
7272

@@ -88,7 +88,7 @@ def makedirs(self, path, exist_ok=False, mode=511):
8888
self.ftp.mkdir(path, mode)
8989

9090
def rmdir(self, path):
91-
logger.debug(f"Removing folder %s", path)
91+
logger.debug("Removing folder %s", path)
9292
self.ftp.rmdir(path)
9393

9494
def info(self, path):
@@ -122,7 +122,7 @@ def _decode_stat(stat, parent_path=None):
122122
return out
123123

124124
def ls(self, path, detail=False):
125-
logger.debug(f"Listing folder {path}")
125+
logger.debug("Listing folder %s", path)
126126
stats = [self._decode_stat(stat, path) for stat in self.ftp.listdir_iter(path)]
127127
if detail:
128128
return stats
@@ -131,7 +131,7 @@ def ls(self, path, detail=False):
131131
return sorted(paths)
132132

133133
def put(self, lpath, rpath, callback=None, **kwargs):
134-
logger.debug(f"Put file {lpath} into {rpath}")
134+
logger.debug("Put file %s into %s", lpath, rpath)
135135
self.ftp.put(lpath, rpath)
136136

137137
def get_file(self, rpath, lpath, **kwargs):
@@ -146,7 +146,7 @@ def _open(self, path, mode="rb", block_size=None, **kwargs):
146146
If 0, no buffering, if 1, line buffering, if >1, buffer that many
147147
bytes, if None use default from paramiko.
148148
"""
149-
logger.debug(f"Opening file {path}")
149+
logger.debug("Opening file %s", path)
150150
if kwargs.get("autocommit", True) is False:
151151
# writes to temporary file, move on commit
152152
path2 = "/".join([self.temppath, str(uuid.uuid4())])
@@ -167,7 +167,7 @@ def _rm(self, path):
167167
self.ftp.remove(path)
168168

169169
def mv(self, old, new):
170-
logger.debug(f"Renaming {old} into {new}")
170+
logger.debug("Renaming %s into %s", old, new)
171171
self.ftp.posix_rename(old, new)
172172

173173

fsspec/spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ def expand_path(self, path, recursive=False, maxdepth=None, **kwargs):
11871187
def mv(self, path1, path2, recursive=False, maxdepth=None, **kwargs):
11881188
"""Move file(s) from one location to another"""
11891189
if path1 == path2:
1190-
logger.debug(f"{self} mv: The paths are the same, so no files were moved.")
1190+
logger.debug("%s mv: The paths are the same, so no files were moved.", self)
11911191
else:
11921192
self.copy(path1, path2, recursive=recursive, maxdepth=maxdepth)
11931193
self.rm(path1, recursive=recursive)
@@ -1849,7 +1849,7 @@ def read(self, length=-1):
18491849
length = self.size - self.loc
18501850
if self.closed:
18511851
raise ValueError("I/O operation on closed file.")
1852-
logger.debug(f"{self} read: {self.loc} - {self.loc + length}")
1852+
logger.debug("%s read: %i - %i", self, self.loc, self.loc + length)
18531853
if length == 0:
18541854
# don't even bother calling fetch
18551855
return b""

0 commit comments

Comments
 (0)