Change in Section type default behavior#376
Merged
jgrewe merged 8 commits intoG-Node:masterfrom Apr 7, 2020
Merged
Conversation
Changing the print format of the validation error messages in Section and Property init to make them more readable.
Section type should always be set and now is set by default to type='n.s.'. This behaviour is introduced to Section.__init__ and is changed in the base method 'create_section' from type='undefined' to type='n.s.' to ensure equal behaviour.
Since Section type is now always set by default to 'n.s.' the previous section type validations have been updated as well and the corresponding messages have been changed.
Closes G-Node#368 Adds all Section attributes to the Sectionable.create_section method.
jgrewe
approved these changes
Apr 7, 2020
Member
jgrewe
left a comment
There was a problem hiding this comment.
looks good to me, put in a few suggestions for the docstrings
odml/base.py
Outdated
| :param name: The name of the section to create. | ||
| :param type: The type of the section. | ||
| :param name: The name of the section to create. If the name is not | ||
| provided, the uuid of the Property is assigned as its name. |
Member
There was a problem hiding this comment.
..., the 'object id' will be assigned.
odml/base.py
Outdated
| 'n.s.' by default. | ||
| :param oid: object id, UUID string as specified in RFC 4122. If no id | ||
| is provided, an id will be generated and assigned. | ||
| :param definition: String describing the definition of the Section. |
odml/base.py
Outdated
| :param definition: String describing the definition of the Section. | ||
| :param reference: A reference (e.g. an URL) to an external definition | ||
| of the Section. | ||
| :param repository: URL to a repository where this Section can be found. |
Member
There was a problem hiding this comment.
"... in which the Section is defined."
|
|
||
| :param name: string providing the name of the Section. If the name is not | ||
| provided, the uuid of the Property is assigned as its name. | ||
| Section name is a required attribute. |
Member
There was a problem hiding this comment.
"... the object id of the Section..."
Contributor
Author
There was a problem hiding this comment.
Copy paste at its best it seems. Thanks for the catch.
Contributor
Author
There was a problem hiding this comment.
Does not show up as updated since the line below is highlighted. Also changed it in odml/base.py.
04d0919 to
7ae9698
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With recent updates the library now respects and enforces
Section.typeas a required attribute and allows save only with documents where this requirement is satisfied.To allow backwards file compatibility and ease usage,
Section.typeis by default set to the stringn.s.(not specified), which means files where no section type had been specified can be loaded and saved, but will containn.s.as value for allSections.typesthat where previously not specified.Further the validation run before a document can be saved will issue a warning, if a
Section.typewith valuen.s.is encountered and will still refuse to save with an error, if an emptySection.typeis encountered.Further changes in this PR:
base.Sectionable.create_sectionmethod has been updated to conform withSection.__init__. This should close issue Unify Section.__init__ and Sectionable.create_section behavior #368Section.typeand validations in general have been updated to adhere to and reflect the changes and refactored to reduce redundancy in general.