Total Complexity | 2 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # SPDX-FileCopyrightText: 2019 Peter Bittner <[email protected]> |
||
2 | # |
||
3 | # SPDX-License-Identifier: GPL-3.0-or-later |
||
4 | |||
5 | """ |
||
6 | Cross-Python version compatibility. |
||
7 | """ |
||
8 | |||
9 | from argparse import _AppendAction as AppendAction |
||
10 | |||
11 | |||
12 | class ExtendAction(AppendAction): # pragma: no-cover-gt-py37 |
||
13 | """ |
||
14 | Argparse "extend" action for Python < 3.8. |
||
15 | A simplified backport from the Python standard library. |
||
16 | """ |
||
17 | |||
18 | def __call__(self, parser, namespace, values, option_string=None): # noqa: ARG002 |
||
19 | items = getattr(namespace, self.dest, None) |
||
20 | items = [] if items is None else items[:] |
||
21 | items.extend(values) |
||
22 | setattr(namespace, self.dest, items) |
||
23 |