This repository has been archived by the owner on Nov 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathboilerplate_function.py
84 lines (61 loc) · 2.02 KB
/
boilerplate_function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
import argparse
from datapunt_processing import logger
# If you need generic helper functions, put them in our helpers folder
# or reuse the current ones by using this import:
# from helpers.files import create_dir_if_not_exists, unzip, save_file
# Setup logging service
logger = logger()
def your_second_function(argname1, argname2):
"""
Does some great stuff.
Args:
1. argname1: path/in/store
2. argname2: your_file_name.txt
Returns:
A file or check, show some examples.
"""
data = argname1
something = data
logger.info('Another Succes!')
return something
def your_first_function(argname1):
"""
Does some great stuff.
Args:
argname1: path/in/store
Returns:
A file or check, show some examples.
"""
something_2 = 'test2'
logger.info('Succes!')
return something_2
def parser():
"""
Parser function to run arguments from commandline and to add description to sphinx docs.
To see possible styling options: https://pythonhosted.org/an_example_pypi_project/sphinx.html
"""
description = """
Explain what this function does, and add a full commandline example which works:
Use ENV:
``export NAME=envvalue``
Example command line:
``python this_cool_function.py first_argument second_argument``
"""
parser = argparse.ArgumentParser(
description=description)
parser.add_argument('first_arg',
type=str,
help='Explain what must go in, with example.')
parser.add_argument('second_arg',
type=str,
help='Specify the desired output folder path, for example: app/data')
return parser
def main():
# Return all arguments in a list
args = parser().parse_args()
# Run all functions sequential
your_first_function(args.first_arg, args.second_arg)
your_second_function(args.second_arg)
if __name__ == "__main__":
main()