8000 Change error messages related to ISO 8601 · spdx/tools-python@0f72105 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f72105

Browse files
jspeed-meyersarmintaenzertng
authored andcommitted
Change error messages related to ISO 8601
Because the SPDX specification uses a subset of ISO-8601 for datetime values, error messages that request the user use ISO-8601 dates are incorrect. These changes make clear to the user the exact format, as dictated by the SPDX spec, that dates should be specified in. Signed-off-by: John Speed Meyers <jsmeyers@chainguard.dev>
1 parent 613982b commit 0f72105

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

spdx/parsers/rdf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"DOC_NAMESPACE_VALUE": 'Invalid DocumentNamespace value {0}, must contain a scheme (e.g. "https:") '
3737
'and should not contain the "#" delimiter.',
3838
"LL_VALUE": "Invalid licenseListVersion '{0}' must be of the format N.N where N is a number",
39-
"CREATED_VALUE": "Invalid created value '{0}' must be date in ISO 8601 format.",
39+
"CREATED_VALUE": "Invalid created value '{0}' is not in 'YYYY-MM-DDThh:mm:ssZ' format.",
4040
"CREATOR_VALUE": "Invalid creator value '{0}' must be Organization, Tool or Person.",
4141
"EXT_DOC_REF_VALUE": "Failed to extract {0} from ExternalDocumentRef.",
4242
"PKG_SPDX_ID_VALUE": 'SPDXID must be "SPDXRef-[idstring]" where [idstring] is a unique string containing '
@@ -56,9 +56,9 @@
5656
"FILE_TYPE": "Unknown file type.",
5757
"FILE_SINGLE_LICS": "File concluded license must be a license url or spdx:noassertion or spdx:none.",
5858
"REVIEWER_VALUE": "Invalid reviewer value '{0}' must be Organization, Tool or Person.",
59-
"REVIEW_DATE": "Invalid review date value '{0}' must be date in ISO 8601 format.",
59+
"REVIEW_DATE": "Invalid review date value '{0}' is not in 'YYYY-MM-DDThh:mm:ssZ' format.",
6060
"ANNOTATOR_VALUE": "Invalid annotator value '{0}' must be Organization, Tool or Person.",
61-
"ANNOTATION_DATE": "Invalid annotation date value '{0}' must be date in ISO 8601 format.",
61+
"ANNOTATION_DATE": "Invalid annotation date value '{0}' is not in 'YYYY-MM-DDThh:mm:ssZ' format.",
6262
"SNIPPET_SPDX_ID_VALUE": 'SPDXID must be "SPDXRef-[idstring]" where [idstring] is a unique string '
6363
'containing letters, numbers, ".", "-".',
6464
"SNIPPET_SINGLE_LICS": "Snippet Concluded License must be a license url or spdx:noassertion or spdx:none.",

spdx/parsers/tagvalue.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"TOOL_VALUE": "Invalid tool value {0} at line: {1}",
2929
"ORG_VALUE": "Invalid organization value {0} at line: {1}",
3030
"PERSON_VALUE": "Invalid person value {0} at line: {1}",
31-
"CREATED_VALUE_TYPE": "Created value must be date in ISO 8601 format, line: {0}",
31+
"CREATED_VALUE_TYPE": "Created value must be in 'YYYY-MM-DDThh:mm:ssZ' format, line: {0}",
3232
"MORE_THAN_ONE": "Only one {0} allowed, extra at line: {1}",
3333
"CREATOR_COMMENT_VALUE_TYPE": "CreatorComment value must be free form text between <text></text> tags or"
3434
"single line of text, line:{0}",
@@ -50,11 +50,11 @@
5050
'and should not contain the "#" delimiter, line: {0}',
5151
"REVIEWER_VALUE_TYPE": "Invalid Reviewer value must be a Person, Organization or Tool. Line: {0}",
5252
"CREATOR_VALUE_TYPE": "Invalid Reviewer value must be a Person, Organization or Tool. Line: {0}",
53-
"REVIEW_DATE_VALUE_TYPE": "ReviewDate value must be date in ISO 8601 format, line: {0}",
53+
"REVIEW_DATE_VALUE_TYPE": "ReviewDate value must be in 'YYYY-MM-DDThh:mm:ssZ' format, line: {0}",
5454
"REVIEW_COMMENT_VALUE_TYPE": "ReviewComment value must be free form text between <text></text> tags"
5555
"or single line of text, line:{0}",
5656
"ANNOTATOR_VALUE_TYPE": "Invalid Annotator value must be a Person, Organization or Tool. Line: {0}",
57-
"ANNOTATION_DATE_VALUE_TYPE": "AnnotationDate value must be date in ISO 8601 format, line: {0}",
57+
"ANNOTATION_DATE_VALUE_TYPE": "AnnotationDate value must be in 'YYYY-MM-DDThh:mm:ssZ' format, line: {0}",
5858
"ANNOTATION_COMMENT_VALUE_TYPE": "AnnotationComment value must be free form text between <text></text> tags"
5959
"or single line of text, line:{0}",
6060
"ANNOTATION_TYPE_VALUE": 'AnnotationType must be "REVIEW" or "OTHER". Line: {0}',
@@ -89,9 +89,9 @@
8989
"PKG_VERF_CODE_VALUE": "VerificationCode doesn't match verifcode form, line:{0}",
9090
"PRIMARY_PACKAGE_PURPOSE_VALUE": 'PrimaryPackagePurpose must be one of APPLICATION, FRAMEWORK, LIBRARY, CONTAINER, '
9191
'OPERATING-SYSTEM, DEVICE, FIRMWARE, SOURCE, ARCHIVE, FILE, INSTALL, OTHER',
92-
"BUILT_DATE_VALUE_TYPE": "Built date value must be date in ISO 8601 format, line: {0}",
93-
"RELEASE_DATE_VALUE_TYPE": "Release date value must be date in ISO 8601 format, line: {0}",
94-
"VALID_UNTIL_DATE_VALUE_TYPE": "Valid until date value must be date in ISO 8601 format, line: {0}",
92+
"BUILT_DATE_VALUE_TYPE": "Built date value must be in 'YYYY-MM-DDThh:mm:ssZ' format, line: {0}",
93+
"RELEASE_DATE_VALUE_TYPE": "Release date value must be in 'YYYY-MM-DDThh:mm:ssZ' format, line: {0}",
94+
"VALID_UNTIL_DATE_VALUE_TYPE": "Valid until date value must be in 'YYYY-MM-DDThh:mm:ssZ' format, line: {0}",
9595
"FILE_NAME_VALUE": "FileName must be a single line of text, line: {0}",
9696
"FILE_COMMENT_VALUE": "FileComment must be free form text or single line of text, line:{0}",
9797
"FILE_TYPE_VALUE": 'FileType must be one of SOURCE, BINARY, ARCHIVE, APPLICATION, AUDIO, IMAGE, TEXT, VIDEO, '

spdx/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def datetime_iso_format(date):
3434
return date.isoformat() + "Z"
3535

3636

37-
# Matches an iso 8601 date representation
37+
# Matches an ISO-8601 date representation without fractional seconds
3838
DATE_ISO_REGEX = re.compile(
3939
r"(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z", re.UNICODE
4040
)

0 commit comments

Comments
 (0)
0