|
82 | 82 | 'LICS_COMMENT_VALUE' : 'LicenseComment must be free form text, line: {0}', |
83 | 83 | 'LICS_CRS_REF_VALUE' : 'LicenseCrossReference must be uri as single line of text, line: {0}', |
84 | 84 | 'PKG_CPY_TEXT_VALUE' : 'Package copyright text must be free form text, line: {0}', |
| 85 | + 'SNIP_SPDX_ID_VALUE' : 'SPDXID must be "SPDXRef-[idstring]" where [idstring] is a unique string ' |
| 86 | + 'containing letters, numbers, ".", "-".', |
| 87 | + 'SNIPPET_NAME_VALUE' : 'SnippetName must be a single line of text, line: {0}', |
| 88 | + 'SNIP_COMMENT_VALUE' : 'SnippetComment must be free form text, line: {0}', |
| 89 | + 'SNIP_COPYRIGHT_VALUE' : 'SnippetCopyrightText must be one of NOASSERTION, NONE or free form text, line: {0}', |
| 90 | + 'SNIP_LICS_COMMENT_VALUE' : 'SnippetLicenseComments must be free form text, line: {0}', |
85 | 91 | } |
86 | 92 |
|
87 | 93 |
|
@@ -143,6 +149,11 @@ def p_attrib(self, p): |
143 | 149 | | file_contrib |
144 | 150 | | file_dep |
145 | 151 | | file_artifact |
| 152 | + | snip_spdx_id |
| 153 | + | snip_name |
| 154 | + | snip_comment |
| 155 | + | snip_cr_text |
| 156 | + | snip_lic_comment |
146 | 157 | | extr_lic_id |
147 | 158 | | extr_lic_text |
148 | 159 | | extr_lic_name |
@@ -990,6 +1001,124 @@ def p_package_name_1(self, p): |
990 | 1001 | msg = ERROR_MESSAGES['PACKAGE_NAME_VALUE'].format(p.lineno(1)) |
991 | 1002 | self.logger.log(msg) |
992 | 1003 |
|
| 1004 | + def p_snip_spdx_id(self, p): |
| 1005 | + """snip_spdx_id : SNIPPET_SPDX_ID LINE""" |
| 1006 | + try: |
| 1007 | + if six.PY2: |
| 1008 | + value = p[2].decode(encoding='utf-8') |
| 1009 | + else: |
| 1010 | + value = p[2] |
| 1011 | + self.builder.create_snippet(self.document, value) |
| 1012 | + except SPDXValueError: |
| 1013 | + self.error = True |
| 1014 | + msg = ERROR_MESSAGES['SNIP_SPDX_ID_VALUE'].format(p.lineno(2)) |
| 1015 | + self.logger.log(msg) |
| 1016 | + |
| 1017 | + def p_snip_spdx_id_1(self, p): |
| 1018 | + """snip_spdx_id : SNIPPET_SPDX_ID error""" |
| 1019 | + self.error = True |
| 1020 | + msg = ERROR_MESSAGES['SNIP_SPDX_ID_VALUE'].format(p.lineno(1)) |
| 1021 | + self.logger.log(msg) |
| 1022 | + |
| 1023 | + def p_snippet_name(self, p): |
| 1024 | + """snip_name : SNIPPET_NAME LINE""" |
| 1025 | + try: |
| 1026 | + if six.PY2: |
| 1027 | + value = p[2].decode(encoding='utf-8') |
| 1028 | + else: |
| 1029 | + value = p[2] |
| 1030 | + self.builder.set_snippet_name(self.document, value) |
| 1031 | + except OrderError: |
| 1032 | + self.order_error('SnippetName', 'SnippetSPDXID', p.lineno(1)) |
| 1033 | + except CardinalityError: |
| 1034 | + self.more_than_one_error('SnippetName', p.lineno(1)) |
| 1035 | + |
| 1036 | + def p_snippet_name_1(self, p): |
| 1037 | + """snip_name : SNIPPET_NAME error""" |
| 1038 | + self.error = True |
| 1039 | + msg = ERROR_MESSAGES['SNIPPET_NAME_VALUE'].format(p.lineno(1)) |
| 1040 | + self.logger.log(msg) |
| 1041 | + |
| 1042 | + def p_snippet_comment(self, p): |
| 1043 | + """snip_comment : SNIPPET_COMMENT TEXT""" |
| 1044 | + try: |
| 1045 | + if six.PY2: |
| 1046 | + value = p[2].decode(encoding='utf-8') |
| 1047 | + else: |
| 1048 | + value = p[2] |
| 1049 | + self.builder.set_snippet_comment(self.document, value) |
| 1050 | + except OrderError: |
| 1051 | + self.order_error('SnippetComment', 'SnippetSPDXID', p.lineno(1)) |
| 1052 | + except SPDXValueError: |
| 1053 | + self.error = True |
| 1054 | + msg = ERROR_MESSAGES['SNIP_COMMENT_VALUE'].format(p.lineno(2)) |
| 1055 | + self.logger.log(msg) |
| 1056 | + except CardinalityError: |
| 1057 | + self.more_than_one_error('SnippetComment', p.lineno(1)) |
| 1058 | + |
| 1059 | + def p_snippet_comment_1(self, p): |
| 1060 | + """snip_comment : SNIPPET_COMMENT error""" |
| 1061 | + self.error = True |
| 1062 | + msg = ERROR_MESSAGES['SNIP_COMMENT_VALUE'].format(p.lineno(1)) |
| 1063 | + self.logger.log(msg) |
| 1064 | + |
| 1065 | + def p_snippet_cr_text(self, p): |
| 1066 | + """snip_cr_text : SNIPPET_CR_TEXT snip_cr_value""" |
| 1067 | + try: |
| 1068 | + self.builder.set_snippet_copyright(self.document, p[2]) |
| 1069 | + except OrderError: |
| 1070 | + self.order_error('SnippetCopyrightText', 'SnippetSPDXID', p.lineno(1)) |
| 1071 | + except SPDXValueError: |
| 1072 | + self.error = True |
| 1073 | + msg = ERROR_MESSAGES['SNIP_COPYRIGHT_VALUE'].format(p.lineno(2)) |
| 1074 | + self.logger.log(msg) |
| 1075 | + except CardinalityError: |
| 1076 | + self.more_than_one_error('SnippetCopyrightText', p.lineno(1)) |
| 1077 | + |
| 1078 | + def p_snippet_cr_text_1(self, p): |
| 1079 | + """snip_cr_text : SNIPPET_CR_TEXT error""" |
| 1080 | + self.error = True |
| 1081 | + msg = ERROR_MESSAGES['SNIP_COPYRIGHT_VALUE'].format(p.lineno(1)) |
| 1082 | + self.logger.log(msg) |
| 1083 | + |
| 1084 | + def p_snippet_cr_value_1(self, p): |
| 1085 | + """snip_cr_value : TEXT""" |
| 1086 | + if six.PY2: |
| 1087 | + p[0] = p[1].decode(encoding='utf-8') |
| 1088 | + else: |
| 1089 | + p[0] = p[1] |
| 1090 | + |
| 1091 | + def p_snippet_cr_value_2(self, p): |
| 1092 | + """snip_cr_value : NONE""" |
| 1093 | + p[0] = utils.SPDXNone() |
| 1094 | + |
| 1095 | + def p_snippet_cr_value_3(self, p): |
| 1096 | + """snip_cr_value : NO_ASSERT""" |
| 1097 | + p[0] = utils.NoAssert() |
| 1098 | + |
| 1099 | + def p_snippet_lic_comment(self, p): |
| 1100 | + """snip_lic_comment : SNIPPET_LICS_COMMENT TEXT""" |
| 1101 | + try: |
| 1102 | + if six.PY2: |
| 1103 | + value = p[2].decode(encoding='utf-8') |
| 1104 | + else: |
| 1105 | + value = p[2] |
| 1106 | + self.builder.set_snippet_lic_comment(self.document, value) |
| 1107 | + except OrderError: |
| 1108 | + self.order_error('SnippetLicenseComments', 'SnippetSPDXID', p.lineno(1)) |
| 1109 | + except SPDXValueError: |
| 1110 | + self.error = True |
| 1111 | + msg = ERROR_MESSAGES['SNIP_LICS_COMMENT_VALUE'].format(p.lineno(2)) |
| 1112 | + self.logger.log(msg) |
| 1113 | + except CardinalityError: |
| 1114 | + self.more_than_one_error('SnippetLicenseComments', p.lineno(1)) |
| 1115 | + |
| 1116 | + def p_snippet_lic_comment_1(self, p): |
| 1117 | + """snip_lic_comment : SNIPPET_LICS_COMMENT error""" |
| 1118 | + self.error = True |
| 1119 | + msg = ERROR_MESSAGES['SNIP_LICS_COMMENT_VALUE'].format(p.lineno(1)) |
| 1120 | + self.logger.log(msg) |
| 1121 | + |
993 | 1122 | def p_reviewer_1(self, p): |
994 | 1123 | """reviewer : REVIEWER entity""" |
995 | 1124 | self.builder.add_reviewer(self.document, p[2]) |
|
0 commit comments