mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
[Private] function names should be snake_case
This commit is contained in:
parent
d3c9a6504e
commit
d241e38120
|
@ -8,7 +8,7 @@ def test_is_path():
|
|||
fp = "filename.ext"
|
||||
|
||||
# Act
|
||||
it_is = _util.isPath(fp)
|
||||
it_is = _util.is_path(fp)
|
||||
|
||||
# Assert
|
||||
assert it_is
|
||||
|
@ -21,7 +21,7 @@ def test_path_obj_is_path():
|
|||
test_path = Path("filename.ext")
|
||||
|
||||
# Act
|
||||
it_is = _util.isPath(test_path)
|
||||
it_is = _util.is_path(test_path)
|
||||
|
||||
# Assert
|
||||
assert it_is
|
||||
|
@ -33,7 +33,7 @@ def test_is_not_path(tmp_path):
|
|||
pass
|
||||
|
||||
# Act
|
||||
it_is_not = _util.isPath(fp)
|
||||
it_is_not = _util.is_path(fp)
|
||||
|
||||
# Assert
|
||||
assert not it_is_not
|
||||
|
@ -44,7 +44,7 @@ def test_is_directory():
|
|||
directory = "Tests"
|
||||
|
||||
# Act
|
||||
it_is = _util.isDirectory(directory)
|
||||
it_is = _util.is_directory(directory)
|
||||
|
||||
# Assert
|
||||
assert it_is
|
||||
|
@ -55,7 +55,7 @@ def test_is_not_directory():
|
|||
text = "abc"
|
||||
|
||||
# Act
|
||||
it_is_not = _util.isDirectory(text)
|
||||
it_is_not = _util.is_directory(text)
|
||||
|
||||
# Assert
|
||||
assert not it_is_not
|
||||
|
|
|
@ -50,7 +50,7 @@ except ImportError:
|
|||
# Use __version__ instead.
|
||||
from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins
|
||||
from ._binary import i32le, o32be, o32le
|
||||
from ._util import deferred_error, isPath
|
||||
from ._util import deferred_error, is_path
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
|
@ -2251,7 +2251,7 @@ class Image:
|
|||
if isinstance(fp, Path):
|
||||
filename = str(fp)
|
||||
open_fp = True
|
||||
elif isPath(fp):
|
||||
elif is_path(fp):
|
||||
filename = fp
|
||||
open_fp = True
|
||||
elif fp == sys.stdout:
|
||||
|
@ -2259,7 +2259,7 @@ class Image:
|
|||
fp = sys.stdout.buffer
|
||||
except AttributeError:
|
||||
pass
|
||||
if not filename and hasattr(fp, "name") and isPath(fp.name):
|
||||
if not filename and hasattr(fp, "name") and is_path(fp.name):
|
||||
# only set the name for metadata purposes
|
||||
filename = fp.name
|
||||
|
||||
|
@ -3065,7 +3065,7 @@ def open(fp, mode="r", formats=None):
|
|||
filename = ""
|
||||
if isinstance(fp, Path):
|
||||
filename = str(fp.resolve())
|
||||
elif isPath(fp):
|
||||
elif is_path(fp):
|
||||
filename = fp
|
||||
|
||||
if filename:
|
||||
|
|
|
@ -33,7 +33,7 @@ import struct
|
|||
import sys
|
||||
|
||||
from . import Image
|
||||
from ._util import isPath
|
||||
from ._util import is_path
|
||||
|
||||
MAXBLOCK = 65536
|
||||
|
||||
|
@ -99,7 +99,7 @@ class ImageFile(Image.Image):
|
|||
self.decoderconfig = ()
|
||||
self.decodermaxblock = MAXBLOCK
|
||||
|
||||
if isPath(fp):
|
||||
if is_path(fp):
|
||||
# filename
|
||||
self.fp = open(fp, "rb")
|
||||
self.filename = fp
|
||||
|
|
|
@ -33,7 +33,7 @@ from enum import IntEnum
|
|||
from io import BytesIO
|
||||
|
||||
from . import Image
|
||||
from ._util import isDirectory, isPath
|
||||
from ._util import is_directory, is_path
|
||||
|
||||
|
||||
class Layout(IntEnum):
|
||||
|
@ -212,7 +212,7 @@ class FreeTypeFont:
|
|||
"", size, index, encoding, self.font_bytes, layout_engine
|
||||
)
|
||||
|
||||
if isPath(font):
|
||||
if is_path(font):
|
||||
if sys.platform == "win32":
|
||||
font_bytes_path = font if isinstance(font, bytes) else font.encode()
|
||||
try:
|
||||
|
@ -877,7 +877,7 @@ def truetype(font=None, size=10, index=0, encoding="", layout_engine=None):
|
|||
try:
|
||||
return freetype(font)
|
||||
except OSError:
|
||||
if not isPath(font):
|
||||
if not is_path(font):
|
||||
raise
|
||||
ttf_filename = os.path.basename(font)
|
||||
|
||||
|
@ -931,7 +931,7 @@ def load_path(filename):
|
|||
:exception OSError: If the file could not be read.
|
||||
"""
|
||||
for directory in sys.path:
|
||||
if isDirectory(directory):
|
||||
if is_directory(directory):
|
||||
if not isinstance(filename, str):
|
||||
filename = filename.decode("utf-8")
|
||||
try:
|
||||
|
|
|
@ -20,7 +20,7 @@ import sys
|
|||
from io import BytesIO
|
||||
|
||||
from . import Image
|
||||
from ._util import isPath
|
||||
from ._util import is_path
|
||||
|
||||
qt_versions = [
|
||||
["6", "PyQt6"],
|
||||
|
@ -140,7 +140,7 @@ def _toqclass_helper(im):
|
|||
if hasattr(im, "toUtf8"):
|
||||
# FIXME - is this really the best way to do this?
|
||||
im = str(im.toUtf8(), "utf-8")
|
||||
if isPath(im):
|
||||
if is_path(im):
|
||||
im = Image.open(im)
|
||||
exclusive_fp = True
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ import os
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
def isPath(f):
|
||||
def is_path(f):
|
||||
return isinstance(f, (bytes, str, Path))
|
||||
|
||||
|
||||
# Checks if an object is a string, and that it points to a directory.
|
||||
def isDirectory(f):
|
||||
return isPath(f) and os.path.isdir(f)
|
||||
def is_directory(f):
|
||||
"""Checks if an object is a string, and that it points to a directory."""
|
||||
return is_path(f) and os.path.isdir(f)
|
||||
|
||||
|
||||
class deferred_error:
|
||||
|
|
Loading…
Reference in New Issue
Block a user