-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargs_parser.py
More file actions
28 lines (20 loc) · 805 Bytes
/
args_parser.py
File metadata and controls
28 lines (20 loc) · 805 Bytes
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
import notebooks
import argparse
class Parsed_args(object):
def __init__(self):
self.notebook_id = None
def parse(args):
# Parse args into a Parsed_args object and return it
parser = argparse.ArgumentParser ()
parser.add_argument ( "-f", "--file", help="Specify, which file should be loaded" )
parser.add_argument ( "-n", "--notebook", help="Specify, which notebook should be loaded", type=int)
args = parser.parse_args ()
parsed_args = Parsed_args()
notebooks.init ( args.file )
if not args.notebook == None:
if args.notebook < len(notebooks.notebook_list) and args.notebook > -1:
parsed_args.notebook_id = args.notebook
else:
print("Error: notebook id out of bounds")
exit ()
return parsed_args