forked from semcneil/2020-git-intro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.py
More file actions
58 lines (44 loc) · 1.55 KB
/
Copy pathoperators.py
File metadata and controls
58 lines (44 loc) · 1.55 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
#
# operators.py
#
# This is a file to demonstrate open source software collaboration for the
# 2020 CPTR 226 class.
#
# Author: Seth McNeill
# Date: 2020 September 07
# Version: 0.1
# Course: CPTR 226
"""This is a file to demonstrate open source software collaboration for the
2020 CPTR 226 class.
"""
# Includes
import datetime # used for start/end times
import argparse # This gives better commandline argument functionality
import doctest # used for testing the code from docstring examples
# Global Variables
# Functions
def add_something(num1, num2):
"""This function adds two numbers and returns the result
>>> add_something(2,3)
5
>>> add_something(-4, 4)
0
>>> add_something(-3, -5)
-8
"""
return(num1 + num2)
# This runs if the file is run as a script vs included as a module
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--doctest', action='store_true',
help='Pass this flag to run doctest on the script')
start_time = datetime.datetime.now() # save the script start time
args = parser.parse_args() # parse the arguments from the commandline
if(args.doctest):
doctest.testmod(verbose=True) # run the tests in verbose mode
print("-------------------")
added = add_something(4, 5)
print(f'Adding 4 + 5 = {added}')
end_time = datetime.datetime.now() # save the script end time
print(f'{__file__} took {end_time - start_time} s to complete')