def __init__(self,
                 uri_or_path=None,
                 data=None,
                 file_obj=None,
                 rdf_format="",
                 verbose=False,
                 hide_base_schemas=True,
                 hide_implicit_types=True,
                 hide_implicit_preds=True,
                 sparql_endpoint=None,
                 credentials=None,
                 build_all=True):
        """
        Load the graph in memory, then setup all necessary attributes.
        """
        super(Ontospy, self).__init__()

        self.rdflib_graph = None
        self.sparql_endpoint = None
        self.credentials = None  # tuple: auth credentials for endpoint if needed
        self.sources = None
        self.sparqlHelper = None
        self.namespaces = []
        # entities buckets start with 'all_'
        self.all_ontologies = []
        self.all_classes = []
        self.all_properties = []
        self.all_properties_annotation = []
        self.all_properties_object = []
        self.all_properties_datatype = []
        self.all_skos_concepts = []
        self.all_shapes = []
        # self.all_individuals = []
        self.toplayer_classes = []
        self.toplayer_properties = []
        self.toplayer_skos = []
        self.toplayer_shapes = []
        self.OWLTHING = OntoClass(rdflib.OWL.Thing, rdflib.OWL.Class, self.namespaces)

        # finally:
        if uri_or_path or data or file_obj:
            self.load_rdf(uri_or_path, data, file_obj, rdf_format, verbose,
                          hide_base_schemas, hide_implicit_types,
                          hide_implicit_preds)
            if build_all:
                self.build_all(
                    verbose=verbose,
                    hide_base_schemas=hide_base_schemas,
                    hide_implicit_types=hide_implicit_types,
                    hide_implicit_preds=hide_implicit_preds)
        elif sparql_endpoint:  # by default entities are not extracted
            self.load_sparql(sparql_endpoint, verbose, hide_base_schemas,
                             hide_implicit_types, hide_implicit_preds, credentials)
        else:
            pass
def __init__ ( self , uri_or_path = None , data = None , file_obj = None , rdf_format = "" , verbose = False , hide_base_schemas = True , hide_implicit_types = True , hide_implicit_preds = True , sparql_endpoint = None , credentials = None , build_all = True ) : super ( Ontospy , self ) . __init__ ( ) self . rdflib_graph = None self . sparql_endpoint = None self . credentials = None self . sources = None self . sparqlHelper = None self . namespaces = [ ] self . all_ontologies = [ ] self . all_classes = [ ] self . all_properties = [ ] self . all_properties_annotation = [ ] self . all_properties_object = [ ] self . all_properties_datatype = [ ] self . all_skos_concepts = [ ] self . all_shapes = [ ] self . toplayer_classes = [ ] self . toplayer_properties = [ ] self . toplayer_skos = [ ] self . toplayer_shapes = [ ] self . OWLTHING = OntoClass ( rdflib . OWL . Thing , rdflib . OWL . Class , self . namespaces ) if uri_or_path or data or file_obj : self . load_rdf ( uri_or_path , data , file_obj , rdf_format , verbose , hide_base_schemas , hide_implicit_types , hide_implicit_preds ) if build_all : self . build_all ( verbose = verbose , hide_base_schemas = hide_base_schemas , hide_implicit_types = hide_implicit_types , hide_implicit_preds = hide_implicit_preds ) elif sparql_endpoint : self . load_sparql ( sparql_endpoint , verbose , hide_base_schemas , hide_implicit_types , hide_implicit_preds , credentials ) else : pass
Load the graph in memory, then setup all necessary attributes.