-
Notifications
You must be signed in to change notification settings - Fork 29
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
Change in Section type default behavior #376
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..., the 'object id' will be assigned.
odml/base.py
Outdated
: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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"String defining this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... in which the Section is defined."
@@ -27,7 +27,10 @@ class BaseSection(base.Sectionable): | |||
|
|||
: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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... the object id of the Section..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy paste at its best it seems. Thanks for the catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not show up as updated since the line below is highlighted. Also changed it in odml/base.py
.
04d0919
to
7ae9698
Compare
With recent updates the library now respects and enforces
Section.type
as a required attribute and allows save only with documents where this requirement is satisfied.To allow backwards file compatibility and ease usage,
Section.type
is 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.types
that where previously not specified.Further the validation run before a document can be saved will issue a warning, if a
Section.type
with valuen.s.
is encountered and will still refuse to save with an error, if an emptySection.type
is encountered.Further changes in this PR:
base.Sectionable.create_section
method has been updated to conform withSection.__init__
. This should close issue Unify Section.__init__ and Sectionable.create_section behavior #368Section.type
and validations in general have been updated to adhere to and reflect the changes and refactored to reduce redundancy in general.