Skip to content

Commit

Permalink
Support paths
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Dec 10, 2020
1 parent 3712629 commit e5a6c43
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pronto/ontology.py
Expand Up @@ -4,6 +4,7 @@
import typing
import warnings
import weakref
from pathlib import Path
from typing import (
BinaryIO,
Dict,
Expand Down Expand Up @@ -143,18 +144,18 @@ def from_obo_library(

def __init__(
self,
handle: Union[BinaryIO, str, None] = None,
handle: Union[BinaryIO, str, Path, None] = None,
import_depth: int = -1,
timeout: int = 5,
threads: Optional[int] = None,
):
"""Create a new `Ontology` instance.
Arguments:
handle (str, ~typing.BinaryIO, or None): Either the path to a file
or a binary file handle that contains a serialized version of
the ontology. If `None` is given, an empty `Ontology` is
returned and can be populated manually.
handle (str, ~typing.BinaryIO, ~pathlib.Path, or None): Either the
path to a file or a binary file handle that contains a
serialized version of the ontology. If `None` is given, an
empty `Ontology` is returned and can be populated manually.
import_depth (int): The maximum depth of imports to resolve in the
ontology tree. *Note that the library may not behave correctly
when not importing the complete dependency tree, so you should
Expand Down Expand Up @@ -193,8 +194,8 @@ def __init__(
return

# Get the path and the handle from arguments
if isinstance(handle, str):
self.path = handle
if isinstance(handle, (str, Path)):
self.path = handle = str(handle)
self.handle = ctx.enter_context(get_handle(handle, timeout))
_handle = ctx.enter_context(decompress(self.handle))
_detach = False
Expand Down

0 comments on commit e5a6c43

Please sign in to comment.