mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Renamed variable for first part of splitext to root
This commit is contained in:
parent
95194a2050
commit
e0a75b6d69
|
@ -98,13 +98,13 @@ class ImageFont:
|
||||||
def _load_pilfont(self, filename: str) -> None:
|
def _load_pilfont(self, filename: str) -> None:
|
||||||
with open(filename, "rb") as fp:
|
with open(filename, "rb") as fp:
|
||||||
image: ImageFile.ImageFile | None = None
|
image: ImageFile.ImageFile | None = None
|
||||||
filename_body = os.path.splitext(filename)[0]
|
root = os.path.splitext(filename)[0]
|
||||||
|
|
||||||
for ext in (".png", ".gif", ".pbm"):
|
for ext in (".png", ".gif", ".pbm"):
|
||||||
if image:
|
if image:
|
||||||
image.close()
|
image.close()
|
||||||
try:
|
try:
|
||||||
fullname = filename_body + ext
|
fullname = root + ext
|
||||||
image = Image.open(fullname)
|
image = Image.open(fullname)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
@ -115,8 +115,7 @@ class ImageFont:
|
||||||
if image:
|
if image:
|
||||||
image.close()
|
image.close()
|
||||||
|
|
||||||
pre = filename_body
|
msg = f"cannot find glyph data file {root}.{{png|gif|pbm}}"
|
||||||
msg = f"cannot find glyph data file {pre}.{{png|gif|pbm}}"
|
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
|
||||||
self.file = fullname
|
self.file = fullname
|
||||||
|
@ -937,7 +936,7 @@ def load_path(filename: str | bytes) -> ImageFont:
|
||||||
pass
|
pass
|
||||||
msg = f"cannot find font file '{filename}' in `sys.path`"
|
msg = f"cannot find font file '{filename}' in `sys.path`"
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
msg += f" did you mean `ImageFont.load({filename})` instead?"
|
msg += f", did you mean `ImageFont.load({filename})` instead?"
|
||||||
|
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user