use path.open
This commit is contained in:
parent
7e1f617274
commit
445c5690e1
@ -606,10 +606,10 @@ def load_libraryfile(
|
|||||||
stream = io.BufferedReader(gz_stream) # type: ignore
|
stream = io.BufferedReader(gz_stream) # type: ignore
|
||||||
else: # noqa: PLR5501
|
else: # noqa: PLR5501
|
||||||
if use_mmap:
|
if use_mmap:
|
||||||
base_stream = open(path, mode='rb', buffering=0)
|
base_stream = path.open(mode='rb', buffering=0) # noqa: SIM115
|
||||||
stream = mmap.mmap(base_stream.fileno(), 0, access=mmap.ACCESS_READ) # type: ignore
|
stream = mmap.mmap(base_stream.fileno(), 0, access=mmap.ACCESS_READ) # type: ignore
|
||||||
else:
|
else:
|
||||||
stream = open(path, mode='rb')
|
stream = path.open(mode='rb') # noqa: SIM115
|
||||||
return load_library(stream, full_load=full_load, postprocess=postprocess)
|
return load_library(stream, full_load=full_load, postprocess=postprocess)
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ def clean_pattern_vertices(pat: Pattern) -> Pattern:
|
|||||||
|
|
||||||
|
|
||||||
def is_gzipped(path: pathlib.Path) -> bool:
|
def is_gzipped(path: pathlib.Path) -> bool:
|
||||||
with open(path, 'rb') as stream:
|
with path.open('rb') as stream:
|
||||||
magic_bytes = stream.read(2)
|
magic_bytes = stream.read(2)
|
||||||
return magic_bytes == b'\x1f\x8b'
|
return magic_bytes == b'\x1f\x8b'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user