-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenvironment.py
More file actions
44 lines (33 loc) · 977 Bytes
/
environment.py
File metadata and controls
44 lines (33 loc) · 977 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
import getopt
import glob
import os
import constants as cst
class Environment():
def __init__(self, argv):
self.verbose = False
self.debug = False
self.files = []
self.parse(argv)
def parse(self, argv):
try:
opts, args = getopt.getopt(argv[1:], "v", ["debug", "verbose"])
except getopt.GetoptError:
print('main.py [-v | --verbose] [--debug] [ imgpath1, imgpath2, ...]')
sys.exit(2)
if len(args) > 0:
self.files = args
else:
self.files = glob.glob(os.path.join(cst.INPUT_DIR, "*.jpg"))
self.files.sort()
self.configure(opts)
def configure(self, opts):
for opt, arg in opts:
if opt == '-v' or opt == '--verbose':
self.verbose = True
elif opt == '--debug':
self.debug = True
try:
env
except NameError:
env = Environment(sys.argv)