code: def qname(self, uri, generate=False):
          
          try:
              prefix, namespace, name = self.g.namespace_manager.compute_qname(uri, generate=generate)
              qname = ':'.join((prefix, name))
              return qname
          except (KeyError, ValueError) as e:
              return uri.toPython() if isinstance(uri, rdflib.URIRef) else uri
docs: Given a uri return the qname if it exists, otherwise return the uri.