-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.py
More file actions
37 lines (26 loc) · 1.05 KB
/
template.py
File metadata and controls
37 lines (26 loc) · 1.05 KB
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
#!/usr/bin/env python
""" This is a template for python scripts """
# add package imports here, for example we import future to make our code "future-proof" (ie py2 -> py3):
# and argparse to add options to our tool.
from __future__ import absolute_import
import argparse
def get_args():
""" this function grabs input arguments from the command line """
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input-file', help="The input file to use")
parser.add_argument('-o', '--output-file', help="The output file to write to")
args = parser.parse_args()
return args
def my_function(input_file, output_file):
""" A sample function """
print("This is my input file: %s" % input_file)
print("\nThis is my output file: %s" % output_file)
def main():
""" The main routine to run """
# Get the parameters
args = get_args()
# Run the function
my_function(args.input_file, args.output_file)
# Define what to do when the script is run and not imported as a module
if __name__ == '__main__':
main()