Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty_print does not work for non 'namespce'd entities #854

Open
adhamhashibon opened this issue Jun 28, 2023 · 1 comment
Open

Pretty_print does not work for non 'namespce'd entities #854

adhamhashibon opened this issue Jun 28, 2023 · 1 comment
Assignees

Comments

@adhamhashibon
Copy link

seems like pretty_print expects a that all superclasses of a class belong to a loaded name space. If for example we load the FOAF namespace and ontology, which uses internally geo, geo is not loaded as a name space, the superclass of a Person is a geo:SpatialThing. Using pretty_print on a Person instance fails:

a_person=foaf.Person()
pretty_print(a_person)

fails with AttributeError: 'NoneType' object has no attribute 'name' at end of a longish message.

@adhamhashibon adhamhashibon self-assigned this Jun 28, 2023
@adhamhashibon
Copy link
Author

Possible solution:

enhance the generator in _pp_list_of_labels_or_uids to take into account non name spaced entities. Currently this is checked for the root entity assuming all other superclasses belong to the name space.

--> We can add an if else inside the generator like so:

labels = ( f"{entity.label} ({entity.namespace.name} )" if entity.namespace else f"{entity.label}" for entity in entities )

and essentially reduce the lines needed, and get the proper result:

- Ontology individual:
  identifier: d77a2f2e-e460-4b11-919a-15f7fc8f943c
  type: Person (foaf )
  superclasses: Person (foaf ), Spatial Thing, Agent (foaf ), Thing (owl )

will integrate this probably with the fix to issue #853 as it also requires a fix to the pretty_print.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant