(self, line)
Inspect the current entity and display a nice summary of key properties
Inspect the current entity and display a nice summary of key properties
Inspect the current entity and display a nice summary of key properties
def do_info(self, line):
        """Inspect the current entity and display a nice summary of key properties"""
        # opts = [ 'namespaces', 'description', 'overview', 'toplayer', 'parents', 'children', 'stats', 'triples' ]
        opts = self.INFO_OPTS

        if not self.current:
            self._help_noontology()
            return

        line = line.split()
        g = self.current['graph']

        # get arg, or default to 'overview'
        if not line:
            self._printDescription()
            self._printTaxonomy(False)
            self._printClassDomain(False)
            self._printClassRange(False)
            self._printPropertyDomainRange(False)
            # self._printSourceCode(False)
            if self.currentEntity and self.currentEntity['type'] == 'class':
                self._print("Tip: type 'info inferred_usage' to show inherited properties\n----------------")

        elif line[0] == "inferred_usage":
            if self.currentEntity:  # @todo only for classes?
                self._printDescription()
                self._printTaxonomy(False)
                self._printClassDomain(False, True)
                self._printClassRange(False, True)
                self._printPropertyDomainRange(False)
            # self._printSourceCode(False)
            return

        elif line[0] == "toplayer":
            if g.toplayer_classes:
                self._print("Top Classes\n----------------", "IMPORTANT")
            for x in g.toplayer_classes:
                self._print(x.qname)
            if g.toplayer_properties:
                self._print("\nTop Properties\n----------------", "IMPORTANT")
                for x in g.toplayer_properties:
                    self._print(x.qname)
            if g.toplayer_skos:
                self._print("\nTop Concepts (SKOS)\n----------------", "IMPORTANT")
                for x in g.toplayer_skos:
                    self._print(x.qname)

        elif line[0] == "namespaces":
            for x in self.current['graph'].namespaces:
                self._print("@prefix %s: <%s> ." % (x[0], x[1]))

        elif line[0] == "parents":
            if self.currentEntity and self.currentEntity['object'].parents():
                for x in self.currentEntity['object'].parents():
                    self._print(x.qname)
            else:
                self._print("No parents. This is a top level entity.")

        elif line[0] == "children":
            if self.currentEntity and self.currentEntity['object'].children():
                for x in self.currentEntity['object'].children():
                    self._print(x.qname)
            else:
                self._print("No children. This is a leaf node.")

        elif line[0] == "ancestors":
            if self.currentEntity and self.currentEntity['object'].ancestors():
                for x in self.currentEntity['object'].ancestors():
                    self._print(x.qname)
            else:
                self._print("No ancestors. This is a top level entity.")

        elif line[0] == "descendants":
            if self.currentEntity and self.currentEntity['object'].descendants():
                for x in self.currentEntity['object'].descendants():
                    self._print(x.qname)
            else:
                self._print("No descendants. This is a leaf node.")

            return
def do_info ( self , line ) : # opts = [ 'namespaces', 'description', 'overview', 'toplayer', 'parents', 'children', 'stats', 'triples' ] opts = self . INFO_OPTS if not self . current : self . _help_noontology ( ) return line = line . split ( ) g = self . current [ 'graph' ] # get arg, or default to 'overview' if not line : self . _printDescription ( ) self . _printTaxonomy ( False ) self . _printClassDomain ( False ) self . _printClassRange ( False ) self . _printPropertyDomainRange ( False ) # self._printSourceCode(False) if self . currentEntity and self . currentEntity [ 'type' ] == 'class' : self . _print ( "Tip: type 'info inferred_usage' to show inherited properties\n----------------" ) elif line [ 0 ] == "inferred_usage" : if self . currentEntity : # @todo only for classes? self . _printDescription ( ) self . _printTaxonomy ( False ) self . _printClassDomain ( False , True ) self . _printClassRange ( False , True ) self . _printPropertyDomainRange ( False ) # self._printSourceCode(False) return elif line [ 0 ] == "toplayer" : if g . toplayer_classes : self . _print ( "Top Classes\n----------------" , "IMPORTANT" ) for x in g . toplayer_classes : self . _print ( x . qname ) if g . toplayer_properties : self . _print ( "\nTop Properties\n----------------" , "IMPORTANT" ) for x in g . toplayer_properties : self . _print ( x . qname ) if g . toplayer_skos : self . _print ( "\nTop Concepts (SKOS)\n----------------" , "IMPORTANT" ) for x in g . toplayer_skos : self . _print ( x . qname ) elif line [ 0 ] == "namespaces" : for x in self . current [ 'graph' ] . namespaces : self . _print ( "@prefix %s: <%s> ." % ( x [ 0 ] , x [ 1 ] ) ) elif line [ 0 ] == "parents" : if self . currentEntity and self . currentEntity [ 'object' ] . parents ( ) : for x in self . currentEntity [ 'object' ] . parents ( ) : self . _print ( x . qname ) else : self . _print ( "No parents. This is a top level entity." ) elif line [ 0 ] == "children" : if self . currentEntity and self . currentEntity [ 'object' ] . children ( ) : for x in self . currentEntity [ 'object' ] . children ( ) : self . _print ( x . qname ) else : self . _print ( "No children. This is a leaf node." ) elif line [ 0 ] == "ancestors" : if self . currentEntity and self . currentEntity [ 'object' ] . ancestors ( ) : for x in self . currentEntity [ 'object' ] . ancestors ( ) : self . _print ( x . qname ) else : self . _print ( "No ancestors. This is a top level entity." ) elif line [ 0 ] == "descendants" : if self . currentEntity and self . currentEntity [ 'object' ] . descendants ( ) : for x in self . currentEntity [ 'object' ] . descendants ( ) : self . _print ( x . qname ) else : self . _print ( "No descendants. This is a leaf node." ) return