src.hello.Greeter.print_message()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
"""Module documentation goes here."""
5
6
from __future__ import print_function
7
8
__author__ = "First Last"
9
__copyright__ = "Copyright 2018, First Last"
10
__credits__ = ["C D", "A B"]
11
__license__ = "Apache 2.0"
12
__version__ = "1.0.1"
13
__maintainer__ = "First Last"
14
__email__ = "[email protected]"
15
__status__ = "Development"
16
17
import argparse
18
from logzero import logger
19
20
21
def log(function):
22
    """Handy logging decorator."""
23
    def inner(*args, **kwargs):
24
        """Innter method."""
25
        logger.debug(function)
26
        function(*args, **kwargs)
27
    return inner
28
29
30
class Greeter():
31
    """Example function with types documented in the docstring."""
32
33
    def __init__(self):
34
        self.message = 'Hello world!'
35
36
    def set_message(self, message: str):
37
        """Function description."""
38
        self.message = message
39
40
    @log
41
    def print_message(self):
42
        """Function description."""
43
        print(self.message)
44
45
46
def main(args: argparse.Namespace):
47
    """ Main entry point of the app """
48
    Greeter().print_message()
49
    logger.info(args)
50
51
52
if __name__ == "__main__":
53
    PARSER = argparse.ArgumentParser()
54
55
    # Required positional argument
56
    PARSER.add_argument("arg", help="Required positional argument")
57
58
    # Optional argument flag which defaults to False
59
    PARSER.add_argument("-f", "--flag", action="store_true", default=False)
60
61
    # Optional argument which requires a parameter (eg. -d test)
62
    PARSER.add_argument("-n", "--name", action="store", dest="name")
63
64
    # Optional verbosity counter (eg. -v, -vv, -vvv, etc.)
65
    PARSER.add_argument(
66
        "-v",
67
        "--verbose",
68
        action="count",
69
        default=0,
70
        help="Verbosity (-v, -vv, etc)")
71
72
    # Specify output of "--version"
73
    PARSER.add_argument(
74
        "--version",
75
        action="version",
76
        version="%(prog)s (version {version})".format(version=__version__))
77
78
    MYARGS = PARSER.parse_args()
79
    main(MYARGS)
80