Transferring/Copying properties from one class to another

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Transferring/Copying properties from one class to another

GoMa
Hi all,

I like to copy properties from one class to another.

My current approach is, that I append the property entries in is_a from the source class to the destination class.
For example onto.ClassA.is_a.append(onto.ClassB_is_a[0]).  
I figured out some incomprehensible behaviour. Executing the code directly in a python file or the debug console, results in the fact, that the property onto.ClassB_is_a[0] is appended twice to onto.ClassA.
Wrapping the same code in a function, for example def copyProperties(to, from): to.is_a.append(from.is_a[0]) leads to:  

OwlReadySharedBlankNodeError
A ClassConstruct cannot be shared by two ontologies, because it correspond to a RDF blank node. Please create a dupplicate.

I tried to use copy and deepcopy to make a copy of is_a[0] but this doesn't solve the problem.


Can someone explain the behaviour?
What is the preferred way to copy properties from one class to another?


Thank you

Markus
Reply | Threaded
Open this post in threaded view
|

Re: Transferring/Copying properties from one class to another

Jiba
Administrator
Hi,

There was no deepcopy support...

I've just added it in the development version of Owlready!
In addition, class constructs are now automatically deep copied, so OwlReadySharedBlankNodeError should no longer appear.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Transferring/Copying properties from one class to another

GoMa
Thanks Jiba. It works!