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

Change in Section type default behavior #376

Merged
merged 8 commits into from
Apr 7, 2020

Conversation

mpsonntag
Copy link
Contributor

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 string n.s. (not specified), which means files where no section type had been specified can be loaded and saved, but will contain n.s. as value for all Sections.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 value n.s. is encountered and will still refuse to save with an error, if an empty Section.type is encountered.

Further changes in this PR:

  • the base.Sectionable.create_section method has been updated to conform with Section.__init__. This should close issue Unify Section.__init__ and Sectionable.create_section behavior #368
  • Validation messages to increase clarity for the user
  • Tests corresponding to the Section.type and validations in general have been updated to adhere to and reflect the changes and refactored to reduce redundancy in general.

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.
@coveralls
Copy link

coveralls commented Apr 7, 2020

Coverage Status

Coverage decreased (-0.009%) to 76.32% when pulling 04d0919 on mpsonntag:handleSectionType into 4fcfcc9 on G-Node:master.

Copy link
Member

@jgrewe jgrewe left a 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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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..."

Copy link
Contributor Author

@mpsonntag mpsonntag Apr 7, 2020

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.

Copy link
Contributor Author

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.

@jgrewe jgrewe merged commit 01fb08a into G-Node:master Apr 7, 2020
@mpsonntag mpsonntag deleted the handleSectionType branch April 9, 2020 11:31
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

Successfully merging this pull request may close these issues.

None yet

3 participants