Skip to content

Commit e7bbc91

Browse files
committed
Fixes mbj4668#757 - do not require the text about RFC origin for IANA modules
1 parent 58b16df commit e7bbc91

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

pyang/plugins/ietf.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ def setup_ctx(self, ctx):
6363
'IETF_MISSING_TRUST_LEGAL_PROVISIONING', 4,
6464
'RFC 8407: 3.1: '
6565
+ 'The IETF Trust Copyright statement seems to be'
66-
+ ' missing or is not correct (see pyang --ietf-help for details).')
66+
+ ' missing or is not correct'
67+
+ ' (see pyang --ietf-help for details).')
68+
69+
error.add_error_code(
70+
'IETF_MISSING_RFC_TEXT', 4,
71+
'RFC 8407: Appendix B: '
72+
+ 'The text about which RFC this module is part of seems to be'
73+
+ ' missing or is not correct'
74+
+ ' (see pyang --ietf-help for details).')
6775

6876
def pre_validate_ctx(self, ctx, modules):
6977
for mod in modules:
@@ -91,6 +99,11 @@ def v_chk_description(self, ctx, s):
9199
if y >= 2022 and arg.find("Simplified") > 0:
92100
err_add(ctx.errors, s.pos,
93101
'IETF_MISSING_TRUST_LEGAL_PROVISIONING', ())
102+
if s.parent.arg.startswith('ietf-'):
103+
m = re_ietf_rfc.search(arg)
104+
if m is None:
105+
err_add(ctx.errors, s.pos,
106+
'IETF_MISSING_RFC_TEXT', ())
94107
if not self.mmap[s.i_module.arg]['found_2119_keywords']:
95108
if re_2119_keywords.search(arg) is not None:
96109
self.mmap[s.i_module.arg]['found_2119_keywords'] = True
@@ -123,6 +136,9 @@ def print_help():
123136
Relating to IETF Documents
124137
(https://trustee.ietf.org/license-info).
125138
139+
An IETF module (but not an IANA module) must also contain the
140+
following text:
141+
126142
This version of this YANG module is part of RFC XXXX
127143
(https://www.rfc-editor.org/info/rfcXXXX); see the RFC itself
128144
for full legal notices.
@@ -156,13 +172,16 @@ def print_help():
156172
to the license terms contained in, the (Revised|Simplified) BSD License
157173
set forth in Section 4\.c of the IETF Trust's Legal Provisions
158174
Relating to IETF Documents
159-
\(https?://trustee.ietf.org/license-info\)\.
175+
\(https?://trustee.ietf.org/license-info\)\."""
176+
177+
re_tlp = re.compile(re.sub(r'\s+', ' ', tlp_str))
160178

161-
This version of this YANG module is part of
179+
ietf_rfc_str = \
180+
r"""This version of this YANG module is part of
162181
RFC .+(\s+\(https?://www.rfc-editor.org/info/rfc.+\))?; see
163182
the RFC itself for full legal notices\."""
164183

165-
re_tlp = re.compile(re.sub(r'\s+', ' ', tlp_str))
184+
re_ietf_rfc = re.compile(re.sub(r'\s+', ' ', ietf_rfc_str))
166185

167186
re_2119_keywords = re.compile(
168187
r"\b(MUST|REQUIRED|SHOULD|SHALL|RECOMMENDED|MAY|OPTIONAL)\b")

0 commit comments

Comments
 (0)