def __init__(self, handle=None, imports=True, import_depth=-1, timeout=2, parser=None):
        """Create an `Ontology` instance from a file handle or a path.

        Arguments:
            handle (io.IOBase or str): the location of the file (either
                a path on the local filesystem, or a FTP or HTTP URL),
                a readable file handle containing an ontology, or `None`
                to create a new ontology from scratch.
            imports (bool, optional): if `True` (the default), embed the
                ontology imports into the returned instance.
            import_depth (int, optional): The depth up to which the
                imports should be resolved. Setting this to 0 is
                equivalent to setting ``imports`` to `False`. Leave
                as default (-1) to handle all the imports.
            timeout (int, optional): The timeout in seconds for network
                operations.
            parser (~pronto.parser.BaseParser, optional): A parser
                instance to use. Leave to `None` to autodetect.

        """
        self.meta = {}
        self.terms = {}
        self.imports = ()
        self._parsed_by = None

        if handle is None:
            self.path = None
        elif hasattr(handle, 'read'):
            self.path = getattr(handle, 'name', None) \
                     or getattr(handle, 'url', None) \
                     or getattr(handle, 'geturl', lambda: None)()
            self.parse(handle, parser)
        elif isinstance(handle, six.string_types):
            self.path = handle
            with self._get_handle(handle, timeout) as handle:
                self.parse(handle, parser)
        else:
            actual = type(handle).__name__
            raise TypeError("Invalid type for 'handle': expected None, file "
                            "handle or string, found {}".format(actual))

        if handle is not None and self._parsed_by is None:
            raise ValueError("Could not find a suitable parser to parse {}".format(handle))

        self.adopt()
        self.resolve_imports(imports, import_depth, parser)
        self.reference()
def __init__ ( self , handle = None , imports = True , import_depth = - 1 , timeout = 2 , parser = None ) : self . meta = { } self . terms = { } self . imports = ( ) self . _parsed_by = None if handle is None : self . path = None elif hasattr ( handle , 'read' ) : self . path = getattr ( handle , 'name' , None ) or getattr ( handle , 'url' , None ) or getattr ( handle , 'geturl' , lambda : None ) ( ) self . parse ( handle , parser ) elif isinstance ( handle , six . string_types ) : self . path = handle with self . _get_handle ( handle , timeout ) as handle : self . parse ( handle , parser ) else : actual = type ( handle ) . __name__ raise TypeError ( "Invalid type for 'handle': expected None, file " "handle or string, found {}" . format ( actual ) ) if handle is not None and self . _parsed_by is None : raise ValueError ( "Could not find a suitable parser to parse {}" . format ( handle ) ) self . adopt ( ) self . resolve_imports ( imports , import_depth , parser ) self . reference ( )
Create an `Ontology` instance from a file handle or a path.

        Arguments:
            handle (io.IOBase or str): the location of the file (either
                a path on the local filesystem, or a FTP or HTTP URL),
                a readable file handle containing an ontology, or `None`
                to create a new ontology from scratch.
            imports (bool, optional): if `True` (the default), embed the
                ontology imports into the returned instance.
            import_depth (int, optional): The depth up to which the
                imports should be resolved. Setting this to 0 is
                equivalent to setting ``imports`` to `False`. Leave
                as default (-1) to handle all the imports.
            timeout (int, optional): The timeout in seconds for network
                operations.
            parser (~pronto.parser.BaseParser, optional): A parser
                instance to use. Leave to `None` to autodetect.