def ontology2df(self):
        '''Updates self.g or self.path bc you could only choose 1'''

        if isinstance(self.path, str) or isinstance(self.path, p):
            self.path = str(self.path)
            filetype = p(self.path).suffix
            if filetype == '.json':
                self.g = None
                try:
                    records = open_json(self.path)
                    return pd.DataFrame(records)
                except:
                    exit('Json file is not in records format.')
            if filetype == '.pickle':
                self.g = None
                return pickle.load(open(self.path, 'rb'))
            elif filetype == '.ttl' or filetype == '.rdf':
                self.g = rdflib.Graph()
                self.g.parse(self.path, format='turtle')
                return self.get_sparql_dataframe()
            elif filetype == '.nt':
                self.g = rdflib.Graph()
                self.g.parse(self.path, format='nt')
                return self.get_sparql_dataframe()
            elif filetype == '.owl' or filetype == '.xrdf':
                self.g = rdflib.Graph()
                try:
                    self.g.parse(self.path, format='xml')
                except:
                    # some owl formats are more rdf than owl
                    self.g.parse(self.path, format='turtle')
                return self.get_sparql_dataframe()
            else:
                exit('Format options: owl, ttl, df_pickle, rdflib.Graph()')
            try:
                return self.get_sparql_dataframe()
                self.path = None
            except:
                exit('Format options: owl, ttl, df_pickle, rdflib.Graph()')

        elif isinstance(self.g, rdflib.graph.Graph):
            self.path = None
            return self.get_sparql_dataframe()

        else:
            exit('Obj given is not str, pathlib obj, or an rdflib.Graph()')
def ontology2df ( self ) : if isinstance ( self . path , str ) or isinstance ( self . path , p ) : self . path = str ( self . path ) filetype = p ( self . path ) . suffix if filetype == '.json' : self . g = None try : records = open_json ( self . path ) return pd . DataFrame ( records ) except : exit ( 'Json file is not in records format.' ) if filetype == '.pickle' : self . g = None return pickle . load ( open ( self . path , 'rb' ) ) elif filetype == '.ttl' or filetype == '.rdf' : self . g = rdflib . Graph ( ) self . g . parse ( self . path , format = 'turtle' ) return self . get_sparql_dataframe ( ) elif filetype == '.nt' : self . g = rdflib . Graph ( ) self . g . parse ( self . path , format = 'nt' ) return self . get_sparql_dataframe ( ) elif filetype == '.owl' or filetype == '.xrdf' : self . g = rdflib . Graph ( ) try : self . g . parse ( self . path , format = 'xml' ) except : self . g . parse ( self . path , format = 'turtle' ) return self . get_sparql_dataframe ( ) else : exit ( 'Format options: owl, ttl, df_pickle, rdflib.Graph()' ) try : return self . get_sparql_dataframe ( ) self . path = None except : exit ( 'Format options: owl, ttl, df_pickle, rdflib.Graph()' ) elif isinstance ( self . g , rdflib . graph . Graph ) : self . path = None return self . get_sparql_dataframe ( ) else : exit ( 'Obj given is not str, pathlib obj, or an rdflib.Graph()' )
Updates self.g or self.path bc you could only choose 1