Skip to content

Commit 8f024c1

Browse files
committed
Merge branch 'develop' into 'master'
new release See merge request linuxfabrik-icinga-plugins/lib-linux!3
2 parents 39e0984 + 6dda206 commit 8f024c1

File tree

13 files changed

+1118
-268
lines changed

13 files changed

+1118
-268
lines changed

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# needed in order to be able to import from this directory
1+
# needed in order to be able to import from this directory

args.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,49 @@
88

99
# https://git.linuxfabrik.ch/linuxfabrik-icinga-plugins/checks-linux/-/blob/master/CONTRIBUTING.md
1010

11-
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
12-
__version__ = '2020040701'
11+
"""Extends argparse by new input argument data types on demand.
12+
"""
1313

14+
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
15+
__version__ = '2020043001'
1416

15-
def csv(string):
16-
return [x.strip() for x in string.split(',')]
1717

18+
def csv(arg):
19+
"""Returns a list from a `csv` input argument.
20+
"""
1821

19-
def float_or_none(input):
20-
if input is None or str(input.lower()) == 'none':
22+
return [x.strip() for x in arg.split(',')]
23+
24+
25+
def float_or_none(arg):
26+
"""Returns None or float from a `float_or_none` input argument.
27+
"""
28+
29+
if arg is None or str(arg.lower()) == 'none':
2130
return None
22-
return float(input)
31+
return float(arg)
32+
2333

34+
def int_or_none(arg):
35+
"""Returns None or int from a `int_or_none` input argument.
36+
"""
2437

25-
def int_or_none(input):
26-
if input is None or str(input.lower()) == 'none':
38+
if arg is None or str(arg.lower()) == 'none':
2739
return None
28-
return int(input)
40+
return int(arg)
2941

3042

31-
def range_or_none(input):
32-
return str_or_none(input)
43+
def range_or_none(arg):
44+
"""Returns None or range from a `range_or_none` input argument.
45+
"""
3346

47+
return str_or_none(arg)
3448

35-
def str_or_none(input):
36-
if input is None or str(input.lower()) == 'none':
37-
return None
38-
return str(input)
3949

50+
def str_or_none(arg):
51+
"""Returns None or str from a `str_or_none` input argument.
52+
"""
53+
54+
if arg is None or str(arg.lower()) == 'none':
55+
return None
56+
return str(arg)

0 commit comments

Comments
 (0)