-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d25546
commit f77ef54
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import abc | ||
from typing.io import BinaryIO | ||
|
||
|
||
class ResourceReader(abc.ABC): | ||
|
||
"""Abstract base class for loaders to provide resource reading support.""" | ||
|
||
@abc.abstractmethod | ||
def open_resource(self, path: str) -> BinaryIO: | ||
"""Return an opened, file-like object for binary reading of the resource. | ||
The 'path' argument is expected to represent only a file name. | ||
If the resource cannot be found, FileNotFoundError is raised. | ||
""" | ||
raise FileNotFoundError | ||
|
||
def resource_path(self, path: str) -> str: | ||
"""Return the file system path to the specified resource. | ||
The 'path' argument is expected to represent only a file name. | ||
If the resource does not exist on the file system, raise | ||
FileNotFoundError. | ||
""" | ||
raise FileNotFoundError |