xml2rfc 3.26.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. xml2rfc/__init__.py +68 -0
  2. xml2rfc/boilerplate_id_guidelines.py +28 -0
  3. xml2rfc/boilerplate_rfc_7841.py +575 -0
  4. xml2rfc/boilerplate_tlp.py +258 -0
  5. xml2rfc/data/SVG-1.2-RFC.rnc +1666 -0
  6. xml2rfc/data/SVG-1.2-RFC.rng +7460 -0
  7. xml2rfc/data/Scripts.txt +2693 -0
  8. xml2rfc/data/metadata.js +218 -0
  9. xml2rfc/data/metadata.min.js +1 -0
  10. xml2rfc/data/reference.rnc +955 -0
  11. xml2rfc/data/reference.rng +2158 -0
  12. xml2rfc/data/referencegroup.rnc +16 -0
  13. xml2rfc/data/referencegroup.rng +2180 -0
  14. xml2rfc/data/rfc7991.rnc +955 -0
  15. xml2rfc/data/rfc7991.rng +2143 -0
  16. xml2rfc/data/v2.rnc +309 -0
  17. xml2rfc/data/v2.rng +720 -0
  18. xml2rfc/data/v3.rnc +1144 -0
  19. xml2rfc/data/v3.rng +2538 -0
  20. xml2rfc/data/v3compat.dtd +630 -0
  21. xml2rfc/data/v3compat.rnc +985 -0
  22. xml2rfc/data/xml2rfc-v3-emacs-nxml.rnc +1083 -0
  23. xml2rfc/data/xml2rfc.css +1171 -0
  24. xml2rfc/data/xml2rfc.js +7 -0
  25. xml2rfc/debug.py +221 -0
  26. xml2rfc/log.py +54 -0
  27. xml2rfc/parser.py +815 -0
  28. xml2rfc/run.py +801 -0
  29. xml2rfc/scripts.py +52 -0
  30. xml2rfc/strings.py +26 -0
  31. xml2rfc/templates/address_card.html +21 -0
  32. xml2rfc/templates/base.html +415 -0
  33. xml2rfc/templates/doc.xml +367 -0
  34. xml2rfc/templates/doc.yaml +2138 -0
  35. xml2rfc/templates/rfc2629-other.ent +61 -0
  36. xml2rfc/templates/rfc2629-xhtml.ent +170 -0
  37. xml2rfc/templates/rfc2629.dtd +328 -0
  38. xml2rfc/uniscripts/__init__.py +97 -0
  39. xml2rfc/uniscripts/unidata.py +306 -0
  40. xml2rfc/uniscripts/update/make_unidata.py +94 -0
  41. xml2rfc/util/__init__.py +7 -0
  42. xml2rfc/util/date.py +94 -0
  43. xml2rfc/util/fonts.py +53 -0
  44. xml2rfc/util/name.py +229 -0
  45. xml2rfc/util/num.py +119 -0
  46. xml2rfc/util/postal.py +285 -0
  47. xml2rfc/util/unicode.py +441 -0
  48. xml2rfc/utils.py +672 -0
  49. xml2rfc/walkpdf.py +113 -0
  50. xml2rfc/writers/__init__.py +25 -0
  51. xml2rfc/writers/base.py +2248 -0
  52. xml2rfc/writers/bib.py +43 -0
  53. xml2rfc/writers/doc.py +354 -0
  54. xml2rfc/writers/expand.py +51 -0
  55. xml2rfc/writers/expanded_xml.py +39 -0
  56. xml2rfc/writers/html.py +3110 -0
  57. xml2rfc/writers/legacy_html.py +860 -0
  58. xml2rfc/writers/nroff.py +345 -0
  59. xml2rfc/writers/paginated_txt.py +432 -0
  60. xml2rfc/writers/pdf.py +230 -0
  61. xml2rfc/writers/preptool.py +2428 -0
  62. xml2rfc/writers/raw_txt.py +1453 -0
  63. xml2rfc/writers/text.py +5000 -0
  64. xml2rfc/writers/unprep.py +187 -0
  65. xml2rfc/writers/v2v3.py +1150 -0
  66. xml2rfc-3.26.0.dist-info/LICENSE +29 -0
  67. xml2rfc-3.26.0.dist-info/METADATA +178 -0
  68. xml2rfc-3.26.0.dist-info/RECORD +71 -0
  69. xml2rfc-3.26.0.dist-info/WHEEL +5 -0
  70. xml2rfc-3.26.0.dist-info/entry_points.txt +2 -0
  71. xml2rfc-3.26.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,218 @@
1
+ /*Copyright (c) 2019 IETF Trust. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice,
7
+ this list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software
15
+ without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ */
28
+ async function addMetadata() {
29
+
30
+ // Copy all CSS rules for "#identifiers" to "#metadata"
31
+ try {
32
+ const cssRules = document.styleSheets[0].cssRules;
33
+ for (let i = 0; i < cssRules.length; i++) {
34
+ if (/#identifiers/.exec(cssRules[i].selectorText)) {
35
+ const rule = cssRules[i].cssText.
36
+ replace('#identifiers','#external-updates');
37
+ document.styleSheets[0].
38
+ insertRule(rule, document.styleSheets[0].cssRules.length);
39
+ }
40
+ }
41
+ } catch (e) {
42
+ console.log(e);
43
+ }
44
+
45
+ function getMeta(metaName) {
46
+ const metas = document.getElementsByTagName('meta');
47
+
48
+ for (let i = 0; i < metas.length; i++) {
49
+ if (metas[i].getAttribute('name') === metaName) {
50
+ return metas[i].getAttribute('content');
51
+ }
52
+ }
53
+
54
+ return '';
55
+ }
56
+
57
+ // Retrieve the "metadata" element from the document
58
+ const div = document.getElementById('external-metadata');
59
+ if (!div) {
60
+ console.log("Could not locate metadata <div> element");
61
+ return;
62
+ }
63
+
64
+ // Insert the external metadata block
65
+ try {
66
+
67
+ var jsonfile;
68
+ var metadata = '';
69
+ var rfcnum = getMeta('rfc.number');
70
+ if (rfcnum) {
71
+ jsonfile = 'https://www.rfc-editor.org/rfc/rfc'+rfcnum+'.json';
72
+ try {
73
+ const response = await fetch(jsonfile);
74
+ metadata = (await response.json());
75
+ } catch(e) {
76
+ if (document.URL.indexOf('html') >= 0){
77
+ jsonfile = document.URL.replace(/html$/,'json');
78
+ } else {
79
+ jsonfile = document.URL + '.json';
80
+ }
81
+ const response = await fetch(jsonfile);
82
+ metadata = (await response.json());
83
+ }
84
+ }
85
+ if (! metadata) {
86
+ return;
87
+ }
88
+ div.style.display = 'block';
89
+
90
+ //const base_url = 'https//www.rfc-editor.org';
91
+ const base_url = '';
92
+ const datatracker_base= 'https://datatracker.ietf.org/doc';
93
+ const ipr_base ='https://datatracker.ietf.org/ipr/search';
94
+ const info_page = 'https://www.rfc-editor.org/info';
95
+ //const base_url = 'http://pubtest.rfc-editor.org';
96
+
97
+
98
+ const doc_id = metadata['doc_id'].toLowerCase();
99
+ const doc_id_str = metadata['doc_id'].slice(0,3).toLowerCase();
100
+ const doc_id_num = metadata['doc_id'].slice(3).replace(/^0+/,'');
101
+
102
+ const label = {
103
+ 'status': 'Status',
104
+ 'obsoletes': 'Obsoletes',
105
+ 'obsoleted_by': 'Obsoleted By',
106
+ 'updates': 'Updates',
107
+ 'updated_by': 'Updated By',
108
+ 'see_also': 'See Also',
109
+ 'errata_url': 'Errata',
110
+ };
111
+
112
+ let metadataHTML = "<dl style='overflow:hidden' id='external-updates'>";
113
+ ['status', 'obsoletes', 'obsoleted_by', 'updates',
114
+ 'updated_by', 'see_also', 'errata_url'].forEach(key => {
115
+ //if (metadata[key]){
116
+ if (key == 'status'){
117
+ metadata[key] = metadata[key].toLowerCase();
118
+ var status_array = metadata[key].split(" ");
119
+ var sLen = status_array.length;
120
+ var status_string="",s_counter =1;
121
+ for (let i=0;i<sLen;i++){
122
+ if (s_counter < sLen){
123
+ status_string = status_string + capitalizeFirstLetter(status_array[i]) + " ";
124
+ }
125
+ else {
126
+
127
+ status_string = status_string + capitalizeFirstLetter(status_array[i]) ;
128
+ }
129
+ s_counter++;
130
+ }
131
+ metadata[key] = status_string;
132
+ } else if (key == 'obsoletes' || key == 'obsoleted_by' || key == 'updates' || key == 'updated_by'){
133
+ var mLen,metadata_string="",counter=1;
134
+ mLen = metadata[key].length;
135
+
136
+ for (let i=0; i< mLen; i++){
137
+
138
+ if (metadata[key][i]){
139
+ metadata[key][i] = String(metadata[key][i]).toLowerCase();
140
+ if (counter < mLen){
141
+ metadata_string = metadata_string + '<a href=\'' + base_url + '/rfc/'.concat(metadata[key][i]) + '\'>' + metadata[key][i].slice(3) + '</a>'+ ', ';
142
+ }else {
143
+ //alert (typeof metadata[key][i])
144
+ metadata_string = metadata_string + '<a href=\'' + base_url + '/rfc/'.concat(metadata[key][i]) + '\'>' + metadata[key][i].slice(3) + '</a>';
145
+ }
146
+ counter++;
147
+ }
148
+ }
149
+ metadata[key] = metadata_string;
150
+ } else if (key == 'see_also'){
151
+ var seeAlen, see_also_string="",seeAcounter=1;
152
+ seeAlen = metadata[key].length;
153
+ for (let i=0;i<seeAlen;i++){
154
+ if (metadata[key][i]){
155
+ metadata[key][i] = String(metadata[key][i]);
156
+ var see_also_str = metadata[key][i].slice(0,3);
157
+ var see_also_num = metadata[key][i].slice(3).replace(/^0+/,'');
158
+ if (seeAcounter < seeAlen){
159
+ if (see_also_str != 'RFC') {
160
+ see_also_string = see_also_string + '<a href=\'' + base_url + '/' + 'info' + '/' + see_also_str.toLowerCase().concat(see_also_num.toLowerCase()) + '\'>'+ see_also_str + ' ' +see_also_num + '</a>' + ', ';
161
+ } else {
162
+ see_also_string = see_also_string + '<a href=\'' + base_url + '/' + 'info' + '/' + see_also_str.toLowerCase().concat(see_also_num.toLowerCase()) + '\'>'+ see_also_num + '</a>' + ', ';
163
+ }
164
+ }else {
165
+ if (see_also_str != 'RFC') {
166
+ see_also_string = see_also_string + '<a href=\'' + base_url + '/' + 'info' + '/' + see_also_str.toLowerCase().concat(see_also_num.toLowerCase()) + '\'>'+ see_also_str + ' ' +see_also_num + '</a>';
167
+ }else {
168
+ see_also_string = see_also_string + '<a href=\'' + base_url + '/' + 'info' + '/' + see_also_str.toLowerCase().concat(see_also_num.toLowerCase()) + '\'>'+ see_also_num + '</a>';
169
+ }
170
+ }
171
+ seeAcounter++;
172
+ }
173
+ }
174
+ metadata[key] = see_also_string;
175
+ }
176
+ else if (key == 'errata_url'){
177
+ var errata_string="";
178
+ if (metadata[key]){
179
+ errata_string = errata_string + '<a href=\'' +metadata[key] + '\'>' + 'Errata exist' + '</a>' + ' | ' + '<a href=\'' + datatracker_base + '/' + doc_id + '\'>' + 'Datatracker' + '</a>' + '| ' + '<a href=\'' + ipr_base + '/?' + doc_id_str + '='+ doc_id_num + '&submit='+ doc_id_str +'\'>' + 'IPR' +'</a>' + ' | ' + '<a href=\'' + info_page + '/' + doc_id + '\'>' + 'Info page' + '</a>';
180
+ }
181
+ else {
182
+ errata_string = '<a href=\'' + datatracker_base + '/' + doc_id + '\'>' + 'Datatracker' + '</a>' + ' | ' + '<a href=\'' + ipr_base + '/?' + doc_id_str + '='+ doc_id_num + '&submit='+ doc_id_str +'\'>' + 'IPR' +'</a>' + ' | ' + '<a href=\'' + info_page + '/' + doc_id + '\'>' + 'Info page' + '</a>';
183
+
184
+ }
185
+ metadata[key] = errata_string;
186
+ }
187
+
188
+
189
+
190
+
191
+ if (metadata[key] != ""){
192
+
193
+ if (label[key] == 'Errata'){
194
+ metadataHTML += `<dt>More info:</dt><dd>${metadata[key]}</dd>`;
195
+ }else {
196
+ metadataHTML += `<dt>${label[key]}:</dt><dd>${metadata[key]}</dd>`;
197
+ }
198
+ }else {
199
+ if (label[key] == 'Errata'){
200
+ metadataHTML += `<dt>More info:</dt><dd>${metadata[key]}</dd>`;
201
+ }
202
+ }
203
+ //}
204
+ })
205
+ metadataHTML += "</dl>";
206
+ div.innerHTML = metadataHTML;
207
+
208
+ } catch (e) {
209
+ console.log(e);
210
+ }
211
+
212
+ function capitalizeFirstLetter(string) {
213
+ return string.charAt(0).toUpperCase() + string.slice(1);
214
+ }
215
+
216
+ }
217
+ window.removeEventListener('load', addMetadata);
218
+ window.addEventListener('load',addMetadata);
@@ -0,0 +1 @@
1
+ async function addMetadata(){try{const e=document.styleSheets[0].cssRules;for(let t=0;t<e.length;t++)if(/#identifiers/.exec(e[t].selectorText)){const a=e[t].cssText.replace("#identifiers","#external-updates");document.styleSheets[0].insertRule(a,document.styleSheets[0].cssRules.length)}}catch(e){console.log(e)}const e=document.getElementById("external-metadata");if(e)try{var t,a="",o=function(e){const t=document.getElementsByTagName("meta");for(let a=0;a<t.length;a++)if(t[a].getAttribute("name")===e)return t[a].getAttribute("content");return""}("rfc.number");if(o){t="https://www.rfc-editor.org/rfc/rfc"+o+".json";try{const e=await fetch(t);a=await e.json()}catch(e){t=document.URL.indexOf("html")>=0?document.URL.replace(/html$/,"json"):document.URL+".json";const o=await fetch(t);a=await o.json()}}if(!a)return;e.style.display="block";const s="",d="https://datatracker.ietf.org/doc",n="https://datatracker.ietf.org/ipr/search",c="https://www.rfc-editor.org/info",l=a.doc_id.toLowerCase(),i=a.doc_id.slice(0,3).toLowerCase(),f=a.doc_id.slice(3).replace(/^0+/,""),u={status:"Status",obsoletes:"Obsoletes",obsoleted_by:"Obsoleted By",updates:"Updates",updated_by:"Updated By",see_also:"See Also",errata_url:"Errata"};let h="<dl style='overflow:hidden' id='external-updates'>";["status","obsoletes","obsoleted_by","updates","updated_by","see_also","errata_url"].forEach(e=>{if("status"==e){a[e]=a[e].toLowerCase();var t=a[e].split(" "),o=t.length,w="",p=1;for(let e=0;e<o;e++)p<o?w=w+r(t[e])+" ":w+=r(t[e]),p++;a[e]=w}else if("obsoletes"==e||"obsoleted_by"==e||"updates"==e||"updated_by"==e){var g,m="",b=1;g=a[e].length;for(let t=0;t<g;t++)a[e][t]&&(a[e][t]=String(a[e][t]).toLowerCase(),m=b<g?m+"<a href='"+s+"/rfc/".concat(a[e][t])+"'>"+a[e][t].slice(3)+"</a>, ":m+"<a href='"+s+"/rfc/".concat(a[e][t])+"'>"+a[e][t].slice(3)+"</a>",b++);a[e]=m}else if("see_also"==e){var y,L="",C=1;y=a[e].length;for(let t=0;t<y;t++)if(a[e][t]){a[e][t]=String(a[e][t]);var _=a[e][t].slice(0,3),v=a[e][t].slice(3).replace(/^0+/,"");L=C<y?"RFC"!=_?L+"<a href='"+s+"/info/"+_.toLowerCase().concat(v.toLowerCase())+"'>"+_+" "+v+"</a>, ":L+"<a href='"+s+"/info/"+_.toLowerCase().concat(v.toLowerCase())+"'>"+v+"</a>, ":"RFC"!=_?L+"<a href='"+s+"/info/"+_.toLowerCase().concat(v.toLowerCase())+"'>"+_+" "+v+"</a>":L+"<a href='"+s+"/info/"+_.toLowerCase().concat(v.toLowerCase())+"'>"+v+"</a>",C++}a[e]=L}else if("errata_url"==e){var R="";R=a[e]?R+"<a href='"+a[e]+"'>Errata exist</a> | <a href='"+d+"/"+l+"'>Datatracker</a>| <a href='"+n+"/?"+i+"="+f+"&submit="+i+"'>IPR</a> | <a href='"+c+"/"+l+"'>Info page</a>":"<a href='"+d+"/"+l+"'>Datatracker</a> | <a href='"+n+"/?"+i+"="+f+"&submit="+i+"'>IPR</a> | <a href='"+c+"/"+l+"'>Info page</a>",a[e]=R}""!=a[e]?"Errata"==u[e]?h+=`<dt>More info:</dt><dd>${a[e]}</dd>`:h+=`<dt>${u[e]}:</dt><dd>${a[e]}</dd>`:"Errata"==u[e]&&(h+=`<dt>More info:</dt><dd>${a[e]}</dd>`)}),h+="</dl>",e.innerHTML=h}catch(e){console.log(e)}else console.log("Could not locate metadata <div> element");function r(e){return e.charAt(0).toUpperCase()+e.slice(1)}}window.removeEventListener("load",addMetadata),window.addEventListener("load",addMetadata);