-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_cmd.py
More file actions
40 lines (30 loc) · 786 Bytes
/
config_cmd.py
File metadata and controls
40 lines (30 loc) · 786 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
import glob
import proc
import strings
import json
def find_files(fpattern):
return glob.glob(fpattern)
def display_files(files):
if files:
print("Founded config files")
for i in range(len(files)):
print(i, ")", files[i])
if not files:
print("No config files found")
def select_file(files):
try:
opt = int(input(strings.SLCT_OPT))
except ValueError:
proc.cls()
else:
for i in range(len(files)):
match opt:
case i:
return files[i]
def open_config(fname):
return json.load(open(fname))
def init_config():
fpattern = "configJSONS/*.json"
files = find_files(fpattern)
display_files(files)
return open_config(select_file(files))