python-odml
python-odml copied to clipboard
Refactoring of repository-attribute handling
The repository attribute should be handled automatically and not manually.
In the current implementation the repository can anyway only be used as an attribute in the generation function of a document and not of a section or property. A repository of a section or property can only be set by object.repository = repo
.
A solution here is tightly connected to the suggested changes in how to access and use terminologies in #131. The behaviour I would like to have would look like the following (note: the following example is based on the example in #74):
import odml.terminologies as term
doc1 = odml.Document("my_empty_doc")
doc1.repository
# output: nothing, because it can't be set manually
doc2 = term.get_terminology('http://portal.g-node.org/odml/terminologies/v1.0/terminologies.xml')
doc2.repository
# output: 'http://portal.g-node.org/odml/terminologies/v1.0/terminologies.xml'
doc2.sections[0].repository
# output: 'http://portal.g-node.org/odml/terminologies/v1.0/subject/subject.xml'
# for getting section/property equivalents of a terminology
sec1 = odml.Section("Subject", type="subject")
sec1.get_terminology_equivalent(repository="http://portal.g-node.org/odml/terminologies/v1.0/terminologies.xml")
# output: clone of section object "Subject" of the terminology