tcllib.argparser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A DefaultParser.__init__() 0 5 1
A DefaultParser.parse_args() 0 8 2
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
# pylint: disable=C0111,C0326,C0103
5
6
"""Custom argument parser."""
7
8
import argparse
9
import webbrowser
10
11
12
class DefaultParser(argparse.ArgumentParser):
0 ignored issues
show
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
13
    """argparse parser with some defaults set."""
14
15
    def __init__(self, appname, desc=None):
16
        """Set default name, description, epilogue, arguments."""
17
        homeurl = "https://github.com/mbirth/tcl_ota_check"
18
        super().__init__(prog=appname, description=desc, epilog=homeurl)
19
        self.add_argument("--webdb", help="open web database in browser and exit", action="store_true")
20
21
    def parse_args(self, args=None, namespace=None):
22
        """Parse special args first, defer to parent class second."""
23
        if set(args) & {"--webdb"}:  # if they intersect
24
            webbrowser.open("https://tclota.birth-online.de/", new=2)
25
            raise SystemExit
26
        else:
27
            argx = super().parse_args(args, namespace)
28
            return argx
29