@html-validate/puppeteer-fetch 1.0.0 → 2.1.0
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.
- package/LICENSE +20 -0
- package/dist/index.js +432 -140
- package/package.json +8 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 David Sveningsson <ext@sidvind.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __objRest = (source, exclude) => {
|
|
10
|
-
var target = {};
|
|
11
|
-
for (var prop in source)
|
|
12
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
13
|
-
target[prop] = source[prop];
|
|
14
|
-
if (source != null && __getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
16
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
17
|
-
target[prop] = source[prop];
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
22
9
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
23
10
|
};
|
|
@@ -29,37 +16,38 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
29
16
|
}
|
|
30
17
|
return to;
|
|
31
18
|
};
|
|
32
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
33
27
|
|
|
34
28
|
// node_modules/argparse/lib/sub.js
|
|
35
29
|
var require_sub = __commonJS({
|
|
36
|
-
"node_modules/argparse/lib/sub.js"(
|
|
30
|
+
"node_modules/argparse/lib/sub.js"(exports2, module2) {
|
|
37
31
|
"use strict";
|
|
38
32
|
var { inspect } = require("util");
|
|
39
33
|
module2.exports = function sub(pattern, ...values) {
|
|
40
34
|
let regex = /%(?:(%)|(-)?(\*)?(?:\((\w+)\))?([A-Za-z]))/g;
|
|
41
35
|
let result = pattern.replace(regex, function(_, is_literal, is_left_align, is_padded, name, format) {
|
|
42
|
-
if (is_literal)
|
|
43
|
-
return "%";
|
|
36
|
+
if (is_literal) return "%";
|
|
44
37
|
let padded_count = 0;
|
|
45
38
|
if (is_padded) {
|
|
46
|
-
if (values.length === 0)
|
|
47
|
-
throw new TypeError("not enough arguments for format string");
|
|
39
|
+
if (values.length === 0) throw new TypeError("not enough arguments for format string");
|
|
48
40
|
padded_count = values.shift();
|
|
49
|
-
if (!Number.isInteger(padded_count))
|
|
50
|
-
throw new TypeError("* wants int");
|
|
41
|
+
if (!Number.isInteger(padded_count)) throw new TypeError("* wants int");
|
|
51
42
|
}
|
|
52
43
|
let str;
|
|
53
44
|
if (name !== void 0) {
|
|
54
45
|
let dict = values[0];
|
|
55
|
-
if (typeof dict !== "object" || dict === null)
|
|
56
|
-
|
|
57
|
-
if (!(name in dict))
|
|
58
|
-
throw new TypeError(`no such key: '${name}'`);
|
|
46
|
+
if (typeof dict !== "object" || dict === null) throw new TypeError("format requires a mapping");
|
|
47
|
+
if (!(name in dict)) throw new TypeError(`no such key: '${name}'`);
|
|
59
48
|
str = dict[name];
|
|
60
49
|
} else {
|
|
61
|
-
if (values.length === 0)
|
|
62
|
-
throw new TypeError("not enough arguments for format string");
|
|
50
|
+
if (values.length === 0) throw new TypeError("not enough arguments for format string");
|
|
63
51
|
str = values.shift();
|
|
64
52
|
}
|
|
65
53
|
switch (format) {
|
|
@@ -98,10 +86,57 @@ var require_sub = __commonJS({
|
|
|
98
86
|
|
|
99
87
|
// node_modules/argparse/lib/textwrap.js
|
|
100
88
|
var require_textwrap = __commonJS({
|
|
101
|
-
"node_modules/argparse/lib/textwrap.js"(
|
|
89
|
+
"node_modules/argparse/lib/textwrap.js"(exports2, module2) {
|
|
102
90
|
"use strict";
|
|
103
91
|
var wordsep_simple_re = /([\t\n\x0b\x0c\r ]+)/;
|
|
104
92
|
var TextWrapper = class {
|
|
93
|
+
/*
|
|
94
|
+
* Object for wrapping/filling text. The public interface consists of
|
|
95
|
+
* the wrap() and fill() methods; the other methods are just there for
|
|
96
|
+
* subclasses to override in order to tweak the default behaviour.
|
|
97
|
+
* If you want to completely replace the main wrapping algorithm,
|
|
98
|
+
* you'll probably have to override _wrap_chunks().
|
|
99
|
+
*
|
|
100
|
+
* Several instance attributes control various aspects of wrapping:
|
|
101
|
+
* width (default: 70)
|
|
102
|
+
* the maximum width of wrapped lines (unless break_long_words
|
|
103
|
+
* is false)
|
|
104
|
+
* initial_indent (default: "")
|
|
105
|
+
* string that will be prepended to the first line of wrapped
|
|
106
|
+
* output. Counts towards the line's width.
|
|
107
|
+
* subsequent_indent (default: "")
|
|
108
|
+
* string that will be prepended to all lines save the first
|
|
109
|
+
* of wrapped output; also counts towards each line's width.
|
|
110
|
+
* expand_tabs (default: true)
|
|
111
|
+
* Expand tabs in input text to spaces before further processing.
|
|
112
|
+
* Each tab will become 0 .. 'tabsize' spaces, depending on its position
|
|
113
|
+
* in its line. If false, each tab is treated as a single character.
|
|
114
|
+
* tabsize (default: 8)
|
|
115
|
+
* Expand tabs in input text to 0 .. 'tabsize' spaces, unless
|
|
116
|
+
* 'expand_tabs' is false.
|
|
117
|
+
* replace_whitespace (default: true)
|
|
118
|
+
* Replace all whitespace characters in the input text by spaces
|
|
119
|
+
* after tab expansion. Note that if expand_tabs is false and
|
|
120
|
+
* replace_whitespace is true, every tab will be converted to a
|
|
121
|
+
* single space!
|
|
122
|
+
* fix_sentence_endings (default: false)
|
|
123
|
+
* Ensure that sentence-ending punctuation is always followed
|
|
124
|
+
* by two spaces. Off by default because the algorithm is
|
|
125
|
+
* (unavoidably) imperfect.
|
|
126
|
+
* break_long_words (default: true)
|
|
127
|
+
* Break words longer than 'width'. If false, those words will not
|
|
128
|
+
* be broken, and some lines might be longer than 'width'.
|
|
129
|
+
* break_on_hyphens (default: true)
|
|
130
|
+
* Allow breaking hyphenated words. If true, wrapping will occur
|
|
131
|
+
* preferably on whitespaces and right after hyphens part of
|
|
132
|
+
* compound words.
|
|
133
|
+
* drop_whitespace (default: true)
|
|
134
|
+
* Drop leading and trailing whitespace from lines.
|
|
135
|
+
* max_lines (default: None)
|
|
136
|
+
* Truncate wrapped lines.
|
|
137
|
+
* placeholder (default: ' [...]')
|
|
138
|
+
* Append to the last line of truncated text.
|
|
139
|
+
*/
|
|
105
140
|
constructor(options = {}) {
|
|
106
141
|
let {
|
|
107
142
|
width = 70,
|
|
@@ -130,6 +165,8 @@ var require_textwrap = __commonJS({
|
|
|
130
165
|
this.max_lines = max_lines;
|
|
131
166
|
this.placeholder = placeholder;
|
|
132
167
|
}
|
|
168
|
+
// -- Private methods -----------------------------------------------
|
|
169
|
+
// (possibly useful for subclasses to override)
|
|
133
170
|
_munge_whitespace(text) {
|
|
134
171
|
if (this.expand_tabs) {
|
|
135
172
|
text = text.replace(/\t/g, " ".repeat(this.tabsize));
|
|
@@ -240,6 +277,7 @@ var require_textwrap = __commonJS({
|
|
|
240
277
|
text = this._munge_whitespace(text);
|
|
241
278
|
return this._split(text);
|
|
242
279
|
}
|
|
280
|
+
// -- Public interface ----------------------------------------------
|
|
243
281
|
wrap(text) {
|
|
244
282
|
let chunks = this._split_chunks(text);
|
|
245
283
|
return this._wrap_chunks(chunks);
|
|
@@ -249,12 +287,12 @@ var require_textwrap = __commonJS({
|
|
|
249
287
|
}
|
|
250
288
|
};
|
|
251
289
|
function wrap(text, options = {}) {
|
|
252
|
-
let
|
|
290
|
+
let { width = 70, ...kwargs } = options;
|
|
253
291
|
let w = new TextWrapper(Object.assign({ width }, kwargs));
|
|
254
292
|
return w.wrap(text);
|
|
255
293
|
}
|
|
256
294
|
function fill(text, options = {}) {
|
|
257
|
-
let
|
|
295
|
+
let { width = 70, ...kwargs } = options;
|
|
258
296
|
let w = new TextWrapper(Object.assign({ width }, kwargs));
|
|
259
297
|
return w.fill(text);
|
|
260
298
|
}
|
|
@@ -291,7 +329,7 @@ var require_textwrap = __commonJS({
|
|
|
291
329
|
|
|
292
330
|
// node_modules/argparse/argparse.js
|
|
293
331
|
var require_argparse = __commonJS({
|
|
294
|
-
"node_modules/argparse/argparse.js"(
|
|
332
|
+
"node_modules/argparse/argparse.js"(exports2, module2) {
|
|
295
333
|
"use strict";
|
|
296
334
|
var SUPPRESS = "==SUPPRESS==";
|
|
297
335
|
var OPTIONAL = "?";
|
|
@@ -324,28 +362,23 @@ var require_argparse = __commonJS({
|
|
|
324
362
|
object[name] = value;
|
|
325
363
|
}
|
|
326
364
|
function setdefault(object, name, value) {
|
|
327
|
-
if (!hasattr(object, name))
|
|
328
|
-
object[name] = value;
|
|
365
|
+
if (!hasattr(object, name)) object[name] = value;
|
|
329
366
|
return object[name];
|
|
330
367
|
}
|
|
331
368
|
function delattr(object, name) {
|
|
332
369
|
delete object[name];
|
|
333
370
|
}
|
|
334
371
|
function range(from, to, step = 1) {
|
|
335
|
-
if (arguments.length === 1)
|
|
336
|
-
[to, from] = [from, 0];
|
|
372
|
+
if (arguments.length === 1) [to, from] = [from, 0];
|
|
337
373
|
if (typeof from !== "number" || typeof to !== "number" || typeof step !== "number") {
|
|
338
374
|
throw new TypeError("argument cannot be interpreted as an integer");
|
|
339
375
|
}
|
|
340
|
-
if (step === 0)
|
|
341
|
-
throw new TypeError("range() arg 3 must not be zero");
|
|
376
|
+
if (step === 0) throw new TypeError("range() arg 3 must not be zero");
|
|
342
377
|
let result = [];
|
|
343
378
|
if (step > 0) {
|
|
344
|
-
for (let i = from; i < to; i += step)
|
|
345
|
-
result.push(i);
|
|
379
|
+
for (let i = from; i < to; i += step) result.push(i);
|
|
346
380
|
} else {
|
|
347
|
-
for (let i = from; i > to; i += step)
|
|
348
|
-
result.push(i);
|
|
381
|
+
for (let i = from; i > to; i += step) result.push(i);
|
|
349
382
|
}
|
|
350
383
|
return result;
|
|
351
384
|
}
|
|
@@ -360,14 +393,12 @@ var require_argparse = __commonJS({
|
|
|
360
393
|
result.push(parts[i] + (i + 1 < parts.length ? parts[i + 1] : ""));
|
|
361
394
|
}
|
|
362
395
|
}
|
|
363
|
-
if (!result[result.length - 1])
|
|
364
|
-
result.pop();
|
|
396
|
+
if (!result[result.length - 1]) result.pop();
|
|
365
397
|
return result;
|
|
366
398
|
}
|
|
367
399
|
function _string_lstrip(string, prefix_chars) {
|
|
368
400
|
let idx = 0;
|
|
369
|
-
while (idx < string.length && prefix_chars.includes(string[idx]))
|
|
370
|
-
idx++;
|
|
401
|
+
while (idx < string.length && prefix_chars.includes(string[idx])) idx++;
|
|
371
402
|
return idx ? string.slice(idx) : string;
|
|
372
403
|
}
|
|
373
404
|
function _string_split(string, sep, maxsplit) {
|
|
@@ -378,18 +409,15 @@ var require_argparse = __commonJS({
|
|
|
378
409
|
return result;
|
|
379
410
|
}
|
|
380
411
|
function _array_equal(array1, array2) {
|
|
381
|
-
if (array1.length !== array2.length)
|
|
382
|
-
return false;
|
|
412
|
+
if (array1.length !== array2.length) return false;
|
|
383
413
|
for (let i = 0; i < array1.length; i++) {
|
|
384
|
-
if (array1[i] !== array2[i])
|
|
385
|
-
return false;
|
|
414
|
+
if (array1[i] !== array2[i]) return false;
|
|
386
415
|
}
|
|
387
416
|
return true;
|
|
388
417
|
}
|
|
389
418
|
function _array_remove(array, item) {
|
|
390
419
|
let idx = array.indexOf(item);
|
|
391
|
-
if (idx === -1)
|
|
392
|
-
throw new TypeError(sub("%r not in list", item));
|
|
420
|
+
if (idx === -1) throw new TypeError(sub("%r not in list", item));
|
|
393
421
|
array.splice(idx, 1);
|
|
394
422
|
}
|
|
395
423
|
function _choices_to_array(choices) {
|
|
@@ -407,6 +435,7 @@ var require_argparse = __commonJS({
|
|
|
407
435
|
}
|
|
408
436
|
function _callable(cls) {
|
|
409
437
|
let result = {
|
|
438
|
+
// object is needed for inferred class name
|
|
410
439
|
[cls.name]: function(...args) {
|
|
411
440
|
let this_class = new.target === result || !new.target;
|
|
412
441
|
return Reflect.construct(cls, args, this_class ? cls : new.target);
|
|
@@ -420,7 +449,13 @@ var require_argparse = __commonJS({
|
|
|
420
449
|
try {
|
|
421
450
|
let name = object.constructor.name;
|
|
422
451
|
Object.defineProperty(object, from, {
|
|
423
|
-
value: util.deprecate(object[to], sub(
|
|
452
|
+
value: util.deprecate(object[to], sub(
|
|
453
|
+
"%s.%s() is renamed to %s.%s()",
|
|
454
|
+
name,
|
|
455
|
+
from,
|
|
456
|
+
name,
|
|
457
|
+
to
|
|
458
|
+
)),
|
|
424
459
|
enumerable: false
|
|
425
460
|
});
|
|
426
461
|
} catch {
|
|
@@ -429,24 +464,19 @@ var require_argparse = __commonJS({
|
|
|
429
464
|
function _camelcase_alias(_class) {
|
|
430
465
|
for (let name of Object.getOwnPropertyNames(_class.prototype)) {
|
|
431
466
|
let camelcase = name.replace(/\w_[a-z]/g, (s) => s[0] + s[2].toUpperCase());
|
|
432
|
-
if (camelcase !== name)
|
|
433
|
-
_alias(_class.prototype, camelcase, name);
|
|
467
|
+
if (camelcase !== name) _alias(_class.prototype, camelcase, name);
|
|
434
468
|
}
|
|
435
469
|
return _class;
|
|
436
470
|
}
|
|
437
471
|
function _to_legacy_name(key) {
|
|
438
472
|
key = key.replace(/\w_[a-z]/g, (s) => s[0] + s[2].toUpperCase());
|
|
439
|
-
if (key === "default")
|
|
440
|
-
|
|
441
|
-
if (key === "const")
|
|
442
|
-
key = "constant";
|
|
473
|
+
if (key === "default") key = "defaultValue";
|
|
474
|
+
if (key === "const") key = "constant";
|
|
443
475
|
return key;
|
|
444
476
|
}
|
|
445
477
|
function _to_new_name(key) {
|
|
446
|
-
if (key === "defaultValue")
|
|
447
|
-
|
|
448
|
-
if (key === "constant")
|
|
449
|
-
key = "const";
|
|
478
|
+
if (key === "defaultValue") key = "default";
|
|
479
|
+
if (key === "constant") key = "const";
|
|
450
480
|
key = key.replace(/[A-Z]/g, (c) => "_" + c.toLowerCase());
|
|
451
481
|
return key;
|
|
452
482
|
}
|
|
@@ -454,10 +484,8 @@ var require_argparse = __commonJS({
|
|
|
454
484
|
function _parse_opts(args, descriptor) {
|
|
455
485
|
function get_name() {
|
|
456
486
|
let stack = new Error().stack.split("\n").map((x) => x.match(/^ at (.*) \(.*\)$/)).filter(Boolean).map((m) => m[1]).map((fn) => fn.match(/[^ .]*$/)[0]);
|
|
457
|
-
if (stack.length && stack[0] === get_name.name)
|
|
458
|
-
|
|
459
|
-
if (stack.length && stack[0] === _parse_opts.name)
|
|
460
|
-
stack.shift();
|
|
487
|
+
if (stack.length && stack[0] === get_name.name) stack.shift();
|
|
488
|
+
if (stack.length && stack[0] === _parse_opts.name) stack.shift();
|
|
461
489
|
return stack.length ? stack[0] : "";
|
|
462
490
|
}
|
|
463
491
|
args = Array.from(args);
|
|
@@ -481,7 +509,11 @@ var require_argparse = __commonJS({
|
|
|
481
509
|
}
|
|
482
510
|
if (renames.length) {
|
|
483
511
|
let name = get_name();
|
|
484
|
-
deprecate("camelcase_" + name, sub(
|
|
512
|
+
deprecate("camelcase_" + name, sub(
|
|
513
|
+
"%s(): following options are renamed: %s",
|
|
514
|
+
name,
|
|
515
|
+
renames.map(([a, b]) => sub("%r -> %r", a, b))
|
|
516
|
+
));
|
|
485
517
|
}
|
|
486
518
|
let missing_positionals = [];
|
|
487
519
|
let positional_count = args.length;
|
|
@@ -502,7 +534,11 @@ var require_argparse = __commonJS({
|
|
|
502
534
|
}
|
|
503
535
|
if (renames2.length) {
|
|
504
536
|
let name = get_name();
|
|
505
|
-
deprecate("camelcase_" + name, sub(
|
|
537
|
+
deprecate("camelcase_" + name, sub(
|
|
538
|
+
"%s(): following options are renamed: %s",
|
|
539
|
+
name,
|
|
540
|
+
renames2.map(([a, b]) => sub("%r -> %r", a, b))
|
|
541
|
+
));
|
|
506
542
|
}
|
|
507
543
|
result.push(kwargs);
|
|
508
544
|
kwargs = {};
|
|
@@ -524,19 +560,35 @@ var require_argparse = __commonJS({
|
|
|
524
560
|
}
|
|
525
561
|
}
|
|
526
562
|
if (Object.keys(kwargs).length) {
|
|
527
|
-
throw new TypeError(sub(
|
|
563
|
+
throw new TypeError(sub(
|
|
564
|
+
"%s() got an unexpected keyword argument %r",
|
|
565
|
+
get_name(),
|
|
566
|
+
Object.keys(kwargs)[0]
|
|
567
|
+
));
|
|
528
568
|
}
|
|
529
569
|
if (args.length) {
|
|
530
570
|
let from = Object.entries(descriptor).filter(([k, v]) => k[0] !== "*" && v !== no_default).length;
|
|
531
571
|
let to = Object.entries(descriptor).filter(([k]) => k[0] !== "*").length;
|
|
532
|
-
throw new TypeError(sub(
|
|
572
|
+
throw new TypeError(sub(
|
|
573
|
+
"%s() takes %s positional argument%s but %s %s given",
|
|
574
|
+
get_name(),
|
|
575
|
+
from === to ? sub("from %s to %s", from, to) : to,
|
|
576
|
+
from === to && to === 1 ? "" : "s",
|
|
577
|
+
positional_count,
|
|
578
|
+
positional_count === 1 ? "was" : "were"
|
|
579
|
+
));
|
|
533
580
|
}
|
|
534
581
|
if (missing_positionals.length) {
|
|
535
582
|
let strs = missing_positionals.map(repr);
|
|
536
|
-
if (strs.length > 1)
|
|
537
|
-
strs[strs.length - 1] = "and " + strs[strs.length - 1];
|
|
583
|
+
if (strs.length > 1) strs[strs.length - 1] = "and " + strs[strs.length - 1];
|
|
538
584
|
let str_joined = strs.join(strs.length === 2 ? "" : ", ");
|
|
539
|
-
throw new TypeError(sub(
|
|
585
|
+
throw new TypeError(sub(
|
|
586
|
+
"%s() missing %i required positional argument%s: %s",
|
|
587
|
+
get_name(),
|
|
588
|
+
strs.length,
|
|
589
|
+
strs.length === 1 ? "" : "s",
|
|
590
|
+
str_joined
|
|
591
|
+
));
|
|
540
592
|
}
|
|
541
593
|
return result;
|
|
542
594
|
}
|
|
@@ -585,6 +637,12 @@ var require_argparse = __commonJS({
|
|
|
585
637
|
return items.slice(0);
|
|
586
638
|
}
|
|
587
639
|
var HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
|
|
640
|
+
/*
|
|
641
|
+
* Formatter for generating usage messages and argument help strings.
|
|
642
|
+
*
|
|
643
|
+
* Only the name of this class is considered a public API. All the methods
|
|
644
|
+
* provided by the class are considered an implementation detail.
|
|
645
|
+
*/
|
|
588
646
|
constructor() {
|
|
589
647
|
let [
|
|
590
648
|
prog,
|
|
@@ -603,7 +661,10 @@ var require_argparse = __commonJS({
|
|
|
603
661
|
}
|
|
604
662
|
this._prog = prog;
|
|
605
663
|
this._indent_increment = indent_increment;
|
|
606
|
-
this._max_help_position = Math.min(
|
|
664
|
+
this._max_help_position = Math.min(
|
|
665
|
+
max_help_position,
|
|
666
|
+
Math.max(width - 20, indent_increment * 2)
|
|
667
|
+
);
|
|
607
668
|
this._width = width;
|
|
608
669
|
this._current_indent = 0;
|
|
609
670
|
this._level = 0;
|
|
@@ -613,6 +674,9 @@ var require_argparse = __commonJS({
|
|
|
613
674
|
this._whitespace_matcher = /[ \t\n\r\f\v]+/g;
|
|
614
675
|
this._long_break_matcher = /\n\n\n+/g;
|
|
615
676
|
}
|
|
677
|
+
// ===============================
|
|
678
|
+
// Section and indentation methods
|
|
679
|
+
// ===============================
|
|
616
680
|
_indent() {
|
|
617
681
|
this._current_indent += this._indent_increment;
|
|
618
682
|
this._level += 1;
|
|
@@ -625,6 +689,9 @@ var require_argparse = __commonJS({
|
|
|
625
689
|
_add_item(func, args) {
|
|
626
690
|
this._current_section.items.push([func, args]);
|
|
627
691
|
}
|
|
692
|
+
// ========================
|
|
693
|
+
// Message building methods
|
|
694
|
+
// ========================
|
|
628
695
|
start_section(heading) {
|
|
629
696
|
this._indent();
|
|
630
697
|
let section = this._Section(this, this._current_section, heading);
|
|
@@ -654,7 +721,10 @@ var require_argparse = __commonJS({
|
|
|
654
721
|
}
|
|
655
722
|
let invocation_length = Math.max(...invocations.map((invocation) => invocation.length));
|
|
656
723
|
let action_length = invocation_length + this._current_indent;
|
|
657
|
-
this._action_max_length = Math.max(
|
|
724
|
+
this._action_max_length = Math.max(
|
|
725
|
+
this._action_max_length,
|
|
726
|
+
action_length
|
|
727
|
+
);
|
|
658
728
|
this._add_item(this._format_action.bind(this), [action]);
|
|
659
729
|
}
|
|
660
730
|
}
|
|
@@ -663,6 +733,9 @@ var require_argparse = __commonJS({
|
|
|
663
733
|
this.add_argument(action);
|
|
664
734
|
}
|
|
665
735
|
}
|
|
736
|
+
// =======================
|
|
737
|
+
// Help-formatting methods
|
|
738
|
+
// =======================
|
|
666
739
|
format_help() {
|
|
667
740
|
let help = this._root_section.format_help();
|
|
668
741
|
if (help) {
|
|
@@ -853,7 +926,10 @@ var require_argparse = __commonJS({
|
|
|
853
926
|
return this._fill_text(text, text_width, indent) + "\n\n";
|
|
854
927
|
}
|
|
855
928
|
_format_action(action) {
|
|
856
|
-
let help_position = Math.min(
|
|
929
|
+
let help_position = Math.min(
|
|
930
|
+
this._action_max_length + 2,
|
|
931
|
+
this._max_help_position
|
|
932
|
+
);
|
|
857
933
|
let help_width = Math.max(this._width - help_position, 11);
|
|
858
934
|
let action_width = help_position - this._current_indent - 2;
|
|
859
935
|
let action_header = this._format_action_invocation(action);
|
|
@@ -1041,16 +1117,34 @@ var require_argparse = __commonJS({
|
|
|
1041
1117
|
}
|
|
1042
1118
|
});
|
|
1043
1119
|
var RawDescriptionHelpFormatter = _camelcase_alias(_callable(class RawDescriptionHelpFormatter extends HelpFormatter {
|
|
1120
|
+
/*
|
|
1121
|
+
* Help message formatter which retains any formatting in descriptions.
|
|
1122
|
+
*
|
|
1123
|
+
* Only the name of this class is considered a public API. All the methods
|
|
1124
|
+
* provided by the class are considered an implementation detail.
|
|
1125
|
+
*/
|
|
1044
1126
|
_fill_text(text, width, indent) {
|
|
1045
1127
|
return splitlines(text, true).map((line) => indent + line).join("");
|
|
1046
1128
|
}
|
|
1047
1129
|
}));
|
|
1048
1130
|
var RawTextHelpFormatter = _camelcase_alias(_callable(class RawTextHelpFormatter extends RawDescriptionHelpFormatter {
|
|
1131
|
+
/*
|
|
1132
|
+
* Help message formatter which retains formatting of all help text.
|
|
1133
|
+
*
|
|
1134
|
+
* Only the name of this class is considered a public API. All the methods
|
|
1135
|
+
* provided by the class are considered an implementation detail.
|
|
1136
|
+
*/
|
|
1049
1137
|
_split_lines(text) {
|
|
1050
1138
|
return splitlines(text);
|
|
1051
1139
|
}
|
|
1052
1140
|
}));
|
|
1053
1141
|
var ArgumentDefaultsHelpFormatter = _camelcase_alias(_callable(class ArgumentDefaultsHelpFormatter extends HelpFormatter {
|
|
1142
|
+
/*
|
|
1143
|
+
* Help message formatter which adds default values to argument help.
|
|
1144
|
+
*
|
|
1145
|
+
* Only the name of this class is considered a public API. All the methods
|
|
1146
|
+
* provided by the class are considered an implementation detail.
|
|
1147
|
+
*/
|
|
1054
1148
|
_get_help_string(action) {
|
|
1055
1149
|
let help = action.help;
|
|
1056
1150
|
if (!action.help.includes("%(default)") && !action.help.includes("%(defaultValue)")) {
|
|
@@ -1065,6 +1159,13 @@ var require_argparse = __commonJS({
|
|
|
1065
1159
|
}
|
|
1066
1160
|
}));
|
|
1067
1161
|
var MetavarTypeHelpFormatter = _camelcase_alias(_callable(class MetavarTypeHelpFormatter extends HelpFormatter {
|
|
1162
|
+
/*
|
|
1163
|
+
* Help message formatter which uses the argument 'type' as the default
|
|
1164
|
+
* metavar value (instead of the argument 'dest')
|
|
1165
|
+
*
|
|
1166
|
+
* Only the name of this class is considered a public API. All the methods
|
|
1167
|
+
* provided by the class are considered an implementation detail.
|
|
1168
|
+
*/
|
|
1068
1169
|
_get_default_metavar_for_optional(action) {
|
|
1069
1170
|
return typeof action.type === "function" ? action.type.name : action.type;
|
|
1070
1171
|
}
|
|
@@ -1086,6 +1187,12 @@ var require_argparse = __commonJS({
|
|
|
1086
1187
|
}
|
|
1087
1188
|
}
|
|
1088
1189
|
var ArgumentError = _callable(class ArgumentError extends Error {
|
|
1190
|
+
/*
|
|
1191
|
+
* An error from creating or using an argument (optional or positional).
|
|
1192
|
+
*
|
|
1193
|
+
* The string value of this exception is the message, augmented with
|
|
1194
|
+
* information about the argument that caused it.
|
|
1195
|
+
*/
|
|
1089
1196
|
constructor(argument, message) {
|
|
1090
1197
|
super();
|
|
1091
1198
|
this.name = "ArgumentError";
|
|
@@ -1107,12 +1214,65 @@ var require_argparse = __commonJS({
|
|
|
1107
1214
|
}
|
|
1108
1215
|
});
|
|
1109
1216
|
var ArgumentTypeError = _callable(class ArgumentTypeError extends Error {
|
|
1217
|
+
/*
|
|
1218
|
+
* An error from trying to convert a command line string to a type.
|
|
1219
|
+
*/
|
|
1110
1220
|
constructor(message) {
|
|
1111
1221
|
super(message);
|
|
1112
1222
|
this.name = "ArgumentTypeError";
|
|
1113
1223
|
}
|
|
1114
1224
|
});
|
|
1115
1225
|
var Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(Function) {
|
|
1226
|
+
/*
|
|
1227
|
+
* Information about how to convert command line strings to Python objects.
|
|
1228
|
+
*
|
|
1229
|
+
* Action objects are used by an ArgumentParser to represent the information
|
|
1230
|
+
* needed to parse a single argument from one or more strings from the
|
|
1231
|
+
* command line. The keyword arguments to the Action constructor are also
|
|
1232
|
+
* all attributes of Action instances.
|
|
1233
|
+
*
|
|
1234
|
+
* Keyword Arguments:
|
|
1235
|
+
*
|
|
1236
|
+
* - option_strings -- A list of command-line option strings which
|
|
1237
|
+
* should be associated with this action.
|
|
1238
|
+
*
|
|
1239
|
+
* - dest -- The name of the attribute to hold the created object(s)
|
|
1240
|
+
*
|
|
1241
|
+
* - nargs -- The number of command-line arguments that should be
|
|
1242
|
+
* consumed. By default, one argument will be consumed and a single
|
|
1243
|
+
* value will be produced. Other values include:
|
|
1244
|
+
* - N (an integer) consumes N arguments (and produces a list)
|
|
1245
|
+
* - '?' consumes zero or one arguments
|
|
1246
|
+
* - '*' consumes zero or more arguments (and produces a list)
|
|
1247
|
+
* - '+' consumes one or more arguments (and produces a list)
|
|
1248
|
+
* Note that the difference between the default and nargs=1 is that
|
|
1249
|
+
* with the default, a single value will be produced, while with
|
|
1250
|
+
* nargs=1, a list containing a single value will be produced.
|
|
1251
|
+
*
|
|
1252
|
+
* - const -- The value to be produced if the option is specified and the
|
|
1253
|
+
* option uses an action that takes no values.
|
|
1254
|
+
*
|
|
1255
|
+
* - default -- The value to be produced if the option is not specified.
|
|
1256
|
+
*
|
|
1257
|
+
* - type -- A callable that accepts a single string argument, and
|
|
1258
|
+
* returns the converted value. The standard Python types str, int,
|
|
1259
|
+
* float, and complex are useful examples of such callables. If None,
|
|
1260
|
+
* str is used.
|
|
1261
|
+
*
|
|
1262
|
+
* - choices -- A container of values that should be allowed. If not None,
|
|
1263
|
+
* after a command-line argument has been converted to the appropriate
|
|
1264
|
+
* type, an exception will be raised if it is not a member of this
|
|
1265
|
+
* collection.
|
|
1266
|
+
*
|
|
1267
|
+
* - required -- True if the action must always be specified at the
|
|
1268
|
+
* command line. This is only meaningful for optional command-line
|
|
1269
|
+
* arguments.
|
|
1270
|
+
*
|
|
1271
|
+
* - help -- The help string describing the argument.
|
|
1272
|
+
*
|
|
1273
|
+
* - metavar -- The name to be used for the option's argument with the
|
|
1274
|
+
* help string. If None, the 'dest' value will be used as the name.
|
|
1275
|
+
*/
|
|
1116
1276
|
constructor() {
|
|
1117
1277
|
let [
|
|
1118
1278
|
option_strings,
|
|
@@ -1280,6 +1440,7 @@ var require_argparse = __commonJS({
|
|
|
1280
1440
|
default_value,
|
|
1281
1441
|
required,
|
|
1282
1442
|
help
|
|
1443
|
+
//, metavar
|
|
1283
1444
|
] = _parse_opts(arguments, {
|
|
1284
1445
|
option_strings: no_default,
|
|
1285
1446
|
dest: no_default,
|
|
@@ -1642,6 +1803,22 @@ var require_argparse = __commonJS({
|
|
|
1642
1803
|
}
|
|
1643
1804
|
});
|
|
1644
1805
|
var FileType = _callable(class FileType extends Function {
|
|
1806
|
+
/*
|
|
1807
|
+
* Factory for creating file object types
|
|
1808
|
+
*
|
|
1809
|
+
* Instances of FileType are typically passed as type= arguments to the
|
|
1810
|
+
* ArgumentParser add_argument() method.
|
|
1811
|
+
*
|
|
1812
|
+
* Keyword Arguments:
|
|
1813
|
+
* - mode -- A string indicating how the file is to be opened. Accepts the
|
|
1814
|
+
* same values as the builtin open() function.
|
|
1815
|
+
* - bufsize -- The file's desired buffer size. Accepts the same values as
|
|
1816
|
+
* the builtin open() function.
|
|
1817
|
+
* - encoding -- The file's encoding. Accepts the same values as the
|
|
1818
|
+
* builtin open() function.
|
|
1819
|
+
* - errors -- A string indicating how encoding and decoding errors are to
|
|
1820
|
+
* be handled. Accepts the same value as the builtin open() function.
|
|
1821
|
+
*/
|
|
1645
1822
|
constructor() {
|
|
1646
1823
|
let [
|
|
1647
1824
|
flags,
|
|
@@ -1657,11 +1834,17 @@ var require_argparse = __commonJS({
|
|
|
1657
1834
|
flags: "r",
|
|
1658
1835
|
encoding: void 0,
|
|
1659
1836
|
mode: void 0,
|
|
1837
|
+
// 0o666
|
|
1660
1838
|
autoClose: void 0,
|
|
1839
|
+
// true
|
|
1661
1840
|
emitClose: void 0,
|
|
1841
|
+
// false
|
|
1662
1842
|
start: void 0,
|
|
1843
|
+
// 0
|
|
1663
1844
|
end: void 0,
|
|
1845
|
+
// Infinity
|
|
1664
1846
|
highWaterMark: void 0,
|
|
1847
|
+
// 64 * 1024
|
|
1665
1848
|
fs: void 0
|
|
1666
1849
|
});
|
|
1667
1850
|
super("return arguments.callee.call.apply(arguments.callee, arguments)");
|
|
@@ -1672,22 +1855,14 @@ var require_argparse = __commonJS({
|
|
|
1672
1855
|
});
|
|
1673
1856
|
this._flags = flags;
|
|
1674
1857
|
this._options = {};
|
|
1675
|
-
if (encoding !== void 0)
|
|
1676
|
-
|
|
1677
|
-
if (
|
|
1678
|
-
|
|
1679
|
-
if (
|
|
1680
|
-
|
|
1681
|
-
if (
|
|
1682
|
-
|
|
1683
|
-
if (start !== void 0)
|
|
1684
|
-
this._options.start = start;
|
|
1685
|
-
if (end !== void 0)
|
|
1686
|
-
this._options.end = end;
|
|
1687
|
-
if (highWaterMark !== void 0)
|
|
1688
|
-
this._options.highWaterMark = highWaterMark;
|
|
1689
|
-
if (fs3 !== void 0)
|
|
1690
|
-
this._options.fs = fs3;
|
|
1858
|
+
if (encoding !== void 0) this._options.encoding = encoding;
|
|
1859
|
+
if (mode !== void 0) this._options.mode = mode;
|
|
1860
|
+
if (autoClose !== void 0) this._options.autoClose = autoClose;
|
|
1861
|
+
if (emitClose !== void 0) this._options.emitClose = emitClose;
|
|
1862
|
+
if (start !== void 0) this._options.start = start;
|
|
1863
|
+
if (end !== void 0) this._options.end = end;
|
|
1864
|
+
if (highWaterMark !== void 0) this._options.highWaterMark = highWaterMark;
|
|
1865
|
+
if (fs3 !== void 0) this._options.fs = fs3;
|
|
1691
1866
|
}
|
|
1692
1867
|
call(string) {
|
|
1693
1868
|
if (string === "-") {
|
|
@@ -1721,10 +1896,9 @@ var require_argparse = __commonJS({
|
|
|
1721
1896
|
[util.inspect.custom]() {
|
|
1722
1897
|
let args = [this._flags];
|
|
1723
1898
|
let kwargs = Object.entries(this._options).map(([k, v]) => {
|
|
1724
|
-
if (k === "mode")
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
} };
|
|
1899
|
+
if (k === "mode") v = { value: v, [util.inspect.custom]() {
|
|
1900
|
+
return "0o" + this.value.toString(8);
|
|
1901
|
+
} };
|
|
1728
1902
|
return [k, v];
|
|
1729
1903
|
});
|
|
1730
1904
|
let args_str = [].concat(args.filter((arg) => arg !== -1).map(repr)).concat(kwargs.filter(([, arg]) => arg !== void 0).map(([kw, arg]) => sub("%s=%r", kw, arg))).join(", ");
|
|
@@ -1735,6 +1909,12 @@ var require_argparse = __commonJS({
|
|
|
1735
1909
|
}
|
|
1736
1910
|
});
|
|
1737
1911
|
var Namespace = _callable(class Namespace extends _AttributeHolder() {
|
|
1912
|
+
/*
|
|
1913
|
+
* Simple object for storing attributes.
|
|
1914
|
+
*
|
|
1915
|
+
* Implements equality by attribute names and values, and provides a simple
|
|
1916
|
+
* string representation.
|
|
1917
|
+
*/
|
|
1738
1918
|
constructor(options = {}) {
|
|
1739
1919
|
super();
|
|
1740
1920
|
Object.assign(this, options);
|
|
@@ -1773,7 +1953,10 @@ var require_argparse = __commonJS({
|
|
|
1773
1953
|
this.register("action", "extend", _ExtendAction);
|
|
1774
1954
|
["storeConst", "storeTrue", "storeFalse", "appendConst"].forEach((old_name) => {
|
|
1775
1955
|
let new_name = _to_new_name(old_name);
|
|
1776
|
-
this.register("action", old_name, util.deprecate(
|
|
1956
|
+
this.register("action", old_name, util.deprecate(
|
|
1957
|
+
this._registry_get("action", new_name),
|
|
1958
|
+
sub('{action: "%s"} is renamed to {action: "%s"}', old_name, new_name)
|
|
1959
|
+
));
|
|
1777
1960
|
});
|
|
1778
1961
|
this._get_handler();
|
|
1779
1962
|
this._actions = [];
|
|
@@ -1784,6 +1967,9 @@ var require_argparse = __commonJS({
|
|
|
1784
1967
|
this._negative_number_matcher = /^-\d+$|^-\d*\.\d+$/;
|
|
1785
1968
|
this._has_negative_number_optionals = [];
|
|
1786
1969
|
}
|
|
1970
|
+
// ====================
|
|
1971
|
+
// Registration methods
|
|
1972
|
+
// ====================
|
|
1787
1973
|
register(registry_name, value, object) {
|
|
1788
1974
|
let registry = setdefault(this._registries, registry_name, {});
|
|
1789
1975
|
registry[value] = object;
|
|
@@ -1791,6 +1977,9 @@ var require_argparse = __commonJS({
|
|
|
1791
1977
|
_registry_get(registry_name, value, default_value = void 0) {
|
|
1792
1978
|
return getattr(this._registries[registry_name], value, default_value);
|
|
1793
1979
|
}
|
|
1980
|
+
// ==================================
|
|
1981
|
+
// Namespace default accessor methods
|
|
1982
|
+
// ==================================
|
|
1794
1983
|
set_defaults(kwargs) {
|
|
1795
1984
|
Object.assign(this._defaults, kwargs);
|
|
1796
1985
|
for (let action of this._actions) {
|
|
@@ -1807,6 +1996,9 @@ var require_argparse = __commonJS({
|
|
|
1807
1996
|
}
|
|
1808
1997
|
return this._defaults[dest];
|
|
1809
1998
|
}
|
|
1999
|
+
// =======================
|
|
2000
|
+
// Adding argument actions
|
|
2001
|
+
// =======================
|
|
1810
2002
|
add_argument() {
|
|
1811
2003
|
let [
|
|
1812
2004
|
args,
|
|
@@ -1817,9 +2009,12 @@ var require_argparse = __commonJS({
|
|
|
1817
2009
|
});
|
|
1818
2010
|
if (args.length === 1 && Array.isArray(args[0])) {
|
|
1819
2011
|
args = args[0];
|
|
1820
|
-
deprecate(
|
|
1821
|
-
|
|
1822
|
-
|
|
2012
|
+
deprecate(
|
|
2013
|
+
"argument-array",
|
|
2014
|
+
sub("use add_argument(%(args)s, {...}) instead of add_argument([ %(args)s ], { ... })", {
|
|
2015
|
+
args: args.map(repr).join(", ")
|
|
2016
|
+
})
|
|
2017
|
+
);
|
|
1823
2018
|
}
|
|
1824
2019
|
let chars = this.prefix_chars;
|
|
1825
2020
|
if (!args.length || args.length === 1 && !chars.includes(args[0][0])) {
|
|
@@ -2018,7 +2213,10 @@ var require_argparse = __commonJS({
|
|
|
2018
2213
|
}
|
|
2019
2214
|
_handle_conflict_error(action, conflicting_actions) {
|
|
2020
2215
|
let message = conflicting_actions.length === 1 ? "conflicting option string: %s" : "conflicting option strings: %s";
|
|
2021
|
-
let conflict_string = conflicting_actions.map(([
|
|
2216
|
+
let conflict_string = conflicting_actions.map(([
|
|
2217
|
+
option_string
|
|
2218
|
+
/*, action*/
|
|
2219
|
+
]) => option_string).join(", ");
|
|
2022
2220
|
throw new ArgumentError(action, sub(message, conflict_string));
|
|
2023
2221
|
}
|
|
2024
2222
|
_handle_conflict_resolve(action, conflicting_actions) {
|
|
@@ -2095,6 +2293,26 @@ var require_argparse = __commonJS({
|
|
|
2095
2293
|
}
|
|
2096
2294
|
});
|
|
2097
2295
|
var ArgumentParser2 = _camelcase_alias(_callable(class ArgumentParser extends _AttributeHolder(_ActionsContainer) {
|
|
2296
|
+
/*
|
|
2297
|
+
* Object for parsing command line strings into Python objects.
|
|
2298
|
+
*
|
|
2299
|
+
* Keyword Arguments:
|
|
2300
|
+
* - prog -- The name of the program (default: sys.argv[0])
|
|
2301
|
+
* - usage -- A usage message (default: auto-generated from arguments)
|
|
2302
|
+
* - description -- A description of what the program does
|
|
2303
|
+
* - epilog -- Text following the argument descriptions
|
|
2304
|
+
* - parents -- Parsers whose arguments should be copied into this one
|
|
2305
|
+
* - formatter_class -- HelpFormatter class for printing help messages
|
|
2306
|
+
* - prefix_chars -- Characters that prefix optional arguments
|
|
2307
|
+
* - fromfile_prefix_chars -- Characters that prefix files containing
|
|
2308
|
+
* additional arguments
|
|
2309
|
+
* - argument_default -- The default value for all arguments
|
|
2310
|
+
* - conflict_handler -- String indicating how to handle conflicts
|
|
2311
|
+
* - add_help -- Add a -h/-help option
|
|
2312
|
+
* - allow_abbrev -- Allow long options to be abbreviated unambiguously
|
|
2313
|
+
* - exit_on_error -- Determines whether or not ArgumentParser exits with
|
|
2314
|
+
* error info when an error occurs
|
|
2315
|
+
*/
|
|
2098
2316
|
constructor() {
|
|
2099
2317
|
let [
|
|
2100
2318
|
prog,
|
|
@@ -2111,7 +2329,9 @@ var require_argparse = __commonJS({
|
|
|
2111
2329
|
allow_abbrev,
|
|
2112
2330
|
exit_on_error,
|
|
2113
2331
|
debug,
|
|
2332
|
+
// LEGACY (v1 compatibility), debug mode
|
|
2114
2333
|
version
|
|
2334
|
+
// LEGACY (v1 compatibility), version
|
|
2115
2335
|
] = _parse_opts(arguments, {
|
|
2116
2336
|
prog: void 0,
|
|
2117
2337
|
usage: void 0,
|
|
@@ -2127,13 +2347,21 @@ var require_argparse = __commonJS({
|
|
|
2127
2347
|
allow_abbrev: true,
|
|
2128
2348
|
exit_on_error: true,
|
|
2129
2349
|
debug: void 0,
|
|
2350
|
+
// LEGACY (v1 compatibility), debug mode
|
|
2130
2351
|
version: void 0
|
|
2352
|
+
// LEGACY (v1 compatibility), version
|
|
2131
2353
|
});
|
|
2132
2354
|
if (debug !== void 0) {
|
|
2133
|
-
deprecate(
|
|
2355
|
+
deprecate(
|
|
2356
|
+
"debug",
|
|
2357
|
+
'The "debug" argument to ArgumentParser is deprecated. Please override ArgumentParser.exit function instead.'
|
|
2358
|
+
);
|
|
2134
2359
|
}
|
|
2135
2360
|
if (version !== void 0) {
|
|
2136
|
-
deprecate(
|
|
2361
|
+
deprecate(
|
|
2362
|
+
"version",
|
|
2363
|
+
`The "version" argument to ArgumentParser is deprecated. Please use add_argument(..., { action: 'version', version: 'N', ... }) instead.`
|
|
2364
|
+
);
|
|
2137
2365
|
}
|
|
2138
2366
|
super({
|
|
2139
2367
|
description,
|
|
@@ -2177,28 +2405,43 @@ var require_argparse = __commonJS({
|
|
|
2177
2405
|
return result;
|
|
2178
2406
|
});
|
|
2179
2407
|
this.register("type", "str", String);
|
|
2180
|
-
this.register(
|
|
2408
|
+
this.register(
|
|
2409
|
+
"type",
|
|
2410
|
+
"string",
|
|
2411
|
+
util.deprecate(String, 'use {type:"str"} or {type:String} instead of {type:"string"}')
|
|
2412
|
+
);
|
|
2181
2413
|
let default_prefix = prefix_chars.includes("-") ? "-" : prefix_chars[0];
|
|
2182
2414
|
if (this.add_help) {
|
|
2183
|
-
this.add_argument(
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2415
|
+
this.add_argument(
|
|
2416
|
+
default_prefix + "h",
|
|
2417
|
+
default_prefix.repeat(2) + "help",
|
|
2418
|
+
{
|
|
2419
|
+
action: "help",
|
|
2420
|
+
default: SUPPRESS,
|
|
2421
|
+
help: "show this help message and exit"
|
|
2422
|
+
}
|
|
2423
|
+
);
|
|
2188
2424
|
}
|
|
2189
2425
|
if (version) {
|
|
2190
|
-
this.add_argument(
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2426
|
+
this.add_argument(
|
|
2427
|
+
default_prefix + "v",
|
|
2428
|
+
default_prefix.repeat(2) + "version",
|
|
2429
|
+
{
|
|
2430
|
+
action: "version",
|
|
2431
|
+
default: SUPPRESS,
|
|
2432
|
+
version: this.version,
|
|
2433
|
+
help: "show program's version number and exit"
|
|
2434
|
+
}
|
|
2435
|
+
);
|
|
2196
2436
|
}
|
|
2197
2437
|
for (let parent of parents) {
|
|
2198
2438
|
this._add_container_actions(parent);
|
|
2199
2439
|
Object.assign(this._defaults, parent._defaults);
|
|
2200
2440
|
}
|
|
2201
2441
|
}
|
|
2442
|
+
// =======================
|
|
2443
|
+
// Pretty __repr__ methods
|
|
2444
|
+
// =======================
|
|
2202
2445
|
_get_kwargs() {
|
|
2203
2446
|
let names = [
|
|
2204
2447
|
"prog",
|
|
@@ -2210,6 +2453,9 @@ var require_argparse = __commonJS({
|
|
|
2210
2453
|
];
|
|
2211
2454
|
return names.map((name) => [name, getattr(this, name)]);
|
|
2212
2455
|
}
|
|
2456
|
+
// ==================================
|
|
2457
|
+
// Optional/Positional adding methods
|
|
2458
|
+
// ==================================
|
|
2213
2459
|
add_subparsers() {
|
|
2214
2460
|
let [
|
|
2215
2461
|
kwargs
|
|
@@ -2255,6 +2501,9 @@ var require_argparse = __commonJS({
|
|
|
2255
2501
|
_get_positional_actions() {
|
|
2256
2502
|
return this._actions.filter((action) => !action.option_strings.length);
|
|
2257
2503
|
}
|
|
2504
|
+
// =====================================
|
|
2505
|
+
// Command line argument parsing methods
|
|
2506
|
+
// =====================================
|
|
2258
2507
|
parse_args(args = void 0, namespace = void 0) {
|
|
2259
2508
|
let argv;
|
|
2260
2509
|
[args, argv] = this.parse_known_args(args, namespace);
|
|
@@ -2429,7 +2678,9 @@ var require_argparse = __commonJS({
|
|
|
2429
2678
|
let start_index = 0;
|
|
2430
2679
|
let max_option_string_index = Math.max(-1, ...Object.keys(option_string_indices).map(Number));
|
|
2431
2680
|
while (start_index <= max_option_string_index) {
|
|
2432
|
-
let next_option_string_index = Math.min(
|
|
2681
|
+
let next_option_string_index = Math.min(
|
|
2682
|
+
...Object.keys(option_string_indices).map(Number).filter((index) => index >= start_index)
|
|
2683
|
+
);
|
|
2433
2684
|
if (start_index !== next_option_string_index) {
|
|
2434
2685
|
let positionals_end_index = consume_positionals(start_index);
|
|
2435
2686
|
if (positionals_end_index > start_index) {
|
|
@@ -2455,13 +2706,20 @@ var require_argparse = __commonJS({
|
|
|
2455
2706
|
required_actions.push(_get_action_name(action));
|
|
2456
2707
|
} else {
|
|
2457
2708
|
if (action.default !== void 0 && typeof action.default === "string" && hasattr(namespace, action.dest) && action.default === getattr(namespace, action.dest)) {
|
|
2458
|
-
setattr(
|
|
2709
|
+
setattr(
|
|
2710
|
+
namespace,
|
|
2711
|
+
action.dest,
|
|
2712
|
+
this._get_value(action, action.default)
|
|
2713
|
+
);
|
|
2459
2714
|
}
|
|
2460
2715
|
}
|
|
2461
2716
|
}
|
|
2462
2717
|
}
|
|
2463
2718
|
if (required_actions.length) {
|
|
2464
|
-
this.error(sub(
|
|
2719
|
+
this.error(sub(
|
|
2720
|
+
"the following arguments are required: %s",
|
|
2721
|
+
required_actions.join(", ")
|
|
2722
|
+
));
|
|
2465
2723
|
}
|
|
2466
2724
|
for (let group of this._mutually_exclusive_groups) {
|
|
2467
2725
|
if (group.required) {
|
|
@@ -2560,7 +2818,11 @@ var require_argparse = __commonJS({
|
|
|
2560
2818
|
}
|
|
2561
2819
|
let option_tuples = this._get_option_tuples(arg_string);
|
|
2562
2820
|
if (option_tuples.length > 1) {
|
|
2563
|
-
let options = option_tuples.map(([
|
|
2821
|
+
let options = option_tuples.map(([
|
|
2822
|
+
,
|
|
2823
|
+
option_string
|
|
2824
|
+
/*, explicit_arg*/
|
|
2825
|
+
]) => option_string).join(", ");
|
|
2564
2826
|
let args = { option: arg_string, matches: options };
|
|
2565
2827
|
let msg = "ambiguous option: %(option)s could match %(matches)s";
|
|
2566
2828
|
this.error(sub(msg, args));
|
|
@@ -2645,6 +2907,9 @@ var require_argparse = __commonJS({
|
|
|
2645
2907
|
}
|
|
2646
2908
|
return nargs_pattern;
|
|
2647
2909
|
}
|
|
2910
|
+
// ========================
|
|
2911
|
+
// Alt command line argument parsing, allowing free intermix
|
|
2912
|
+
// ========================
|
|
2648
2913
|
parse_intermixed_args(args = void 0, namespace = void 0) {
|
|
2649
2914
|
let argv;
|
|
2650
2915
|
[args, argv] = this.parse_known_intermixed_args(args, namespace);
|
|
@@ -2682,7 +2947,10 @@ var require_argparse = __commonJS({
|
|
|
2682
2947
|
action.save_default = action.default;
|
|
2683
2948
|
action.default = SUPPRESS;
|
|
2684
2949
|
}
|
|
2685
|
-
[namespace, remaining_args] = this.parse_known_args(
|
|
2950
|
+
[namespace, remaining_args] = this.parse_known_args(
|
|
2951
|
+
args,
|
|
2952
|
+
namespace
|
|
2953
|
+
);
|
|
2686
2954
|
for (let action of positionals) {
|
|
2687
2955
|
let attr = getattr(namespace, action.dest);
|
|
2688
2956
|
if (Array.isArray(attr) && attr.length === 0) {
|
|
@@ -2706,7 +2974,10 @@ var require_argparse = __commonJS({
|
|
|
2706
2974
|
group.save_required = group.required;
|
|
2707
2975
|
group.required = false;
|
|
2708
2976
|
}
|
|
2709
|
-
[namespace, extras] = this.parse_known_args(
|
|
2977
|
+
[namespace, extras] = this.parse_known_args(
|
|
2978
|
+
remaining_args,
|
|
2979
|
+
namespace
|
|
2980
|
+
);
|
|
2710
2981
|
} finally {
|
|
2711
2982
|
for (let action of optionals) {
|
|
2712
2983
|
action.required = action.save_required;
|
|
@@ -2720,6 +2991,9 @@ var require_argparse = __commonJS({
|
|
|
2720
2991
|
}
|
|
2721
2992
|
return [namespace, extras];
|
|
2722
2993
|
}
|
|
2994
|
+
// ========================
|
|
2995
|
+
// Value conversion methods
|
|
2996
|
+
// ========================
|
|
2723
2997
|
_get_values(action, arg_strings) {
|
|
2724
2998
|
if (![PARSER, REMAINDER].includes(action.nargs)) {
|
|
2725
2999
|
try {
|
|
@@ -2806,14 +3080,25 @@ var require_argparse = __commonJS({
|
|
|
2806
3080
|
throw new ArgumentError(action, sub(msg, args));
|
|
2807
3081
|
}
|
|
2808
3082
|
}
|
|
3083
|
+
// =======================
|
|
3084
|
+
// Help-formatting methods
|
|
3085
|
+
// =======================
|
|
2809
3086
|
format_usage() {
|
|
2810
3087
|
let formatter = this._get_formatter();
|
|
2811
|
-
formatter.add_usage(
|
|
3088
|
+
formatter.add_usage(
|
|
3089
|
+
this.usage,
|
|
3090
|
+
this._actions,
|
|
3091
|
+
this._mutually_exclusive_groups
|
|
3092
|
+
);
|
|
2812
3093
|
return formatter.format_help();
|
|
2813
3094
|
}
|
|
2814
3095
|
format_help() {
|
|
2815
3096
|
let formatter = this._get_formatter();
|
|
2816
|
-
formatter.add_usage(
|
|
3097
|
+
formatter.add_usage(
|
|
3098
|
+
this.usage,
|
|
3099
|
+
this._actions,
|
|
3100
|
+
this._mutually_exclusive_groups
|
|
3101
|
+
);
|
|
2817
3102
|
formatter.add_text(this.description);
|
|
2818
3103
|
for (let action_group of this._action_groups) {
|
|
2819
3104
|
formatter.start_section(action_group.title);
|
|
@@ -2827,23 +3112,26 @@ var require_argparse = __commonJS({
|
|
|
2827
3112
|
_get_formatter() {
|
|
2828
3113
|
return new this.formatter_class({ prog: this.prog });
|
|
2829
3114
|
}
|
|
3115
|
+
// =====================
|
|
3116
|
+
// Help-printing methods
|
|
3117
|
+
// =====================
|
|
2830
3118
|
print_usage(file = void 0) {
|
|
2831
|
-
if (file === void 0)
|
|
2832
|
-
file = process.stdout;
|
|
3119
|
+
if (file === void 0) file = process.stdout;
|
|
2833
3120
|
this._print_message(this.format_usage(), file);
|
|
2834
3121
|
}
|
|
2835
3122
|
print_help(file = void 0) {
|
|
2836
|
-
if (file === void 0)
|
|
2837
|
-
file = process.stdout;
|
|
3123
|
+
if (file === void 0) file = process.stdout;
|
|
2838
3124
|
this._print_message(this.format_help(), file);
|
|
2839
3125
|
}
|
|
2840
3126
|
_print_message(message, file = void 0) {
|
|
2841
3127
|
if (message) {
|
|
2842
|
-
if (file === void 0)
|
|
2843
|
-
file = process.stderr;
|
|
3128
|
+
if (file === void 0) file = process.stderr;
|
|
2844
3129
|
file.write(message);
|
|
2845
3130
|
}
|
|
2846
3131
|
}
|
|
3132
|
+
// ===============
|
|
3133
|
+
// Exiting methods
|
|
3134
|
+
// ===============
|
|
2847
3135
|
exit(status = 0, message = void 0) {
|
|
2848
3136
|
if (message) {
|
|
2849
3137
|
this._print_message(message, process.stderr);
|
|
@@ -2851,8 +3139,7 @@ var require_argparse = __commonJS({
|
|
|
2851
3139
|
process.exit(status);
|
|
2852
3140
|
}
|
|
2853
3141
|
error(message) {
|
|
2854
|
-
if (this.debug === true)
|
|
2855
|
-
throw new Error(message);
|
|
3142
|
+
if (this.debug === true) throw new Error(message);
|
|
2856
3143
|
this.print_usage(process.stderr);
|
|
2857
3144
|
let args = { prog: this.prog, message };
|
|
2858
3145
|
this.exit(2, sub("%(prog)s: error: %(message)s\n", args));
|
|
@@ -2905,19 +3192,20 @@ var require_argparse = __commonJS({
|
|
|
2905
3192
|
});
|
|
2906
3193
|
|
|
2907
3194
|
// src/index.ts
|
|
2908
|
-
var
|
|
2909
|
-
var
|
|
2910
|
-
var import_puppeteer = __toESM(require("puppeteer"));
|
|
3195
|
+
var import_node_fs = require("node:fs");
|
|
3196
|
+
var import_node_path = __toESM(require("node:path"));
|
|
2911
3197
|
var import_argparse = __toESM(require_argparse());
|
|
3198
|
+
var import_puppeteer = require("puppeteer");
|
|
2912
3199
|
function normalizeUrl(url) {
|
|
2913
|
-
if (url
|
|
3200
|
+
if (/:\/\//.exec(url)) {
|
|
2914
3201
|
return url;
|
|
2915
3202
|
} else {
|
|
2916
3203
|
return `https://${url}`;
|
|
2917
3204
|
}
|
|
2918
3205
|
}
|
|
2919
|
-
|
|
2920
|
-
const
|
|
3206
|
+
async function run() {
|
|
3207
|
+
const content = await import_node_fs.promises.readFile(import_node_path.default.join(__dirname, "../package.json"), "utf-8");
|
|
3208
|
+
const pkg = JSON.parse(content);
|
|
2921
3209
|
const parser = new import_argparse.ArgumentParser({
|
|
2922
3210
|
description: pkg.description
|
|
2923
3211
|
});
|
|
@@ -2927,10 +3215,14 @@ function normalizeUrl(url) {
|
|
|
2927
3215
|
parser.add_argument("url", { help: "URL to fetch", metavar: "URL" });
|
|
2928
3216
|
const args = parser.parse_args();
|
|
2929
3217
|
const url = normalizeUrl(args.url);
|
|
2930
|
-
const browser = await import_puppeteer.
|
|
3218
|
+
const browser = await (0, import_puppeteer.launch)({ headless: false });
|
|
2931
3219
|
const page = await browser.newPage();
|
|
2932
3220
|
await page.goto(url);
|
|
2933
3221
|
const source = await page.content();
|
|
2934
3222
|
await browser.close();
|
|
2935
3223
|
console.log(source);
|
|
2936
|
-
}
|
|
3224
|
+
}
|
|
3225
|
+
run().catch((err) => {
|
|
3226
|
+
console.error(err);
|
|
3227
|
+
process.exitCode = 1;
|
|
3228
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-validate/puppeteer-fetch",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Fetch HTML source from a webpage using Chrome as backend",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"puppeteer",
|
|
@@ -14,21 +14,23 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://gitlab.com/html-validate/puppeteer-fetch.git"
|
|
17
|
+
"url": "git+https://gitlab.com/html-validate/puppeteer-fetch.git"
|
|
18
18
|
},
|
|
19
|
-
"license": "
|
|
19
|
+
"license": "MIT",
|
|
20
20
|
"author": "David Sveningsson <ext@sidvind.com>",
|
|
21
21
|
"main": "dist/index.js",
|
|
22
|
-
"bin":
|
|
22
|
+
"bin": {
|
|
23
|
+
"puppeteer-fetch": "puppeteer-fetch.js"
|
|
24
|
+
},
|
|
23
25
|
"files": [
|
|
24
26
|
"dist",
|
|
25
27
|
"puppeteer-fetch.js"
|
|
26
28
|
],
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"puppeteer": "
|
|
30
|
+
"puppeteer": "24.27.0"
|
|
29
31
|
},
|
|
30
32
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
33
|
+
"node": ">= 20",
|
|
32
34
|
"npm": ">= 7"
|
|
33
35
|
},
|
|
34
36
|
"publishConfig": {
|