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

Upgrade the 'Document' class to the SPDX 2.1 specification #71

Merged
merged 4 commits into from
Aug 7, 2018

Conversation

yash-nisar
Copy link
Contributor

No description provided.

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good... See my comments for a minor change.
As for the validation IMHO you could work out on a cleanup of the way validation works (and how validation messages should be returned rather than a list passed around.)

@@ -189,7 +190,13 @@ class Document(object):
Represent an SPDX document with these fields:
- version: Spec version. Mandatory, one - Type: Version.
- data_license: SPDX-Metadata license. Mandatory, one. Type: License.
- name: Name of the document. Mandatory, one. Type: str.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to make this mandatory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had referred to https://spdx.org/sites/cpstandard/files/pages/files/spdxversion2.1.pdf#page=11 where the Cardinality is Mandatory. So, what should we do ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave as is.

@@ -189,7 +190,13 @@ class Document(object):
Represent an SPDX document with these fields:
- version: Spec version. Mandatory, one - Type: Version.
- data_license: SPDX-Metadata license. Mandatory, one. Type: License.
- name: Name of the document. Mandatory, one. Type: str.
- spdx_id: SPDX Identifier for the document to refer to itself in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to make this mandatory too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had referred to https://spdx.org/sites/cpstandard/files/pages/files/spdxversion2.1.pdf#page=10 where the Cardinality is Mandatory. So, what should we do ?

- comment: Comments on the SPDX file, optional one. Type: str
- namespace: SPDX document specific namespace. Mandatory, one. Type: str
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to make this mandatory again?

Note that your doc does not seem to be what happens: this does not seem mandatory in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    def validate_namespace(self, messages=None):
        # FIXME: messages should be returned
        messages = messages if messages is not None else []

        if self.namespace is None:
            messages.append('Document has no namespace.')
            return False
        else:
            return True

has been defined which will throw an error if the namespace is not defined :)
Do you want me to add additional tests ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's ok for now

@@ -237,11 +252,14 @@ def validate(self, messages=None):

return (self.validate_version(messages)
and self.validate_data_lics(messages)
and self.validate_name(messages)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we likely want the validation to be strict or not.... Note that this PR can still go through and this can be fixed afterwards

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to handle the validation part after Phase 1 ? Is that okay ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@@ -0,0 +1,89 @@

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pombredanne Do you want me to add this in document.py itself ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@pombredanne
Copy link
Member

This needs to be updated to resolve merge conflicts.

Signed-off-by: Yash Nisar <yash.nisar@somaiya.edu>
Signed-off-by: Yash Nisar <yash.nisar@somaiya.edu>
Signed-off-by: Yash Nisar <yash.nisar@somaiya.edu>
Signed-off-by: Yash Nisar <yash.nisar@somaiya.edu>
@yash-nisar
Copy link
Contributor Author

@pombredanne Merge conflicts resolved. Wanna review this one last time ?

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few comments that could be addressed afterwards. Using name like checksum consistently throughout is one of them.
Looking good otherwise and merging

- external_document_id: A unique string containing letters, numbers, '.',
'-' or '+'.
- spdx_document_uri: The unique ID of the SPDX document being referenced.
- check_sum: The checksum of the referenced SPDX document.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why check_sum instead of checksum?

@@ -19,6 +19,78 @@
from spdx import config


@total_ordering
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good usage of this 👍


return (self.validate_ext_doc_id(messages) and
self.validate_spdx_doc_uri(messages) and
self.validate_chksum(messages)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

being consistent would be nice: use checksum everywhere?


if self.external_document_id:
return True
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else is not needed.... but this is minor.

@@ -189,7 +190,13 @@ class Document(object):
Represent an SPDX document with these fields:
- version: Spec version. Mandatory, one - Type: Version.
- data_license: SPDX-Metadata license. Mandatory, one. Type: License.
- name: Name of the document. Mandatory, one. Type: str.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave as is.

- comment: Comments on the SPDX file, optional one. Type: str
- namespace: SPDX document specific namespace. Mandatory, one. Type: str
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's ok for now

@@ -237,11 +252,14 @@ def validate(self, messages=None):

return (self.validate_version(messages)
and self.validate_data_lics(messages)
and self.validate_name(messages)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


def validate_ext_document_references(self, messages=None):
# FIXME: messages should be returned
messages = messages if messages is not None else []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could a simpler messages = messages or [] be enough here and elsewhere?

@pombredanne pombredanne merged commit 0a79680 into spdx:master Aug 7, 2018
@yash-nisar yash-nisar deleted the doc-spec-2.1 branch August 8, 2018 09:10
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.

2 participants