Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pathlib.Path instances #123

Merged
merged 2 commits into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(self, filename):
"""Open a whole-slide image."""
AbstractSlide.__init__(self)
self._filename = filename
self._osr = lowlevel.open(filename)
self._osr = lowlevel.open(str(filename))

def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self._filename)
Expand All @@ -160,7 +160,7 @@ def detect_format(cls, filename):
"""Return a string describing the format vendor of the specified file.

If the file format is not recognized, return None."""
return lowlevel.detect_vendor(filename)
return lowlevel.detect_vendor(str(filename))

def close(self):
"""Close the OpenSlide object."""
Expand Down
4 changes: 3 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from functools import wraps
import os
from pathlib import Path

from PIL import Image
import unittest

Expand Down Expand Up @@ -52,4 +54,4 @@


def file_path(name):
return os.path.join(os.path.dirname(__file__), name)
return Path(__file__).parent / name