-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
71 lines (55 loc) · 1.52 KB
/
config.py
File metadata and controls
71 lines (55 loc) · 1.52 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import yaml
import sys
import os
import readline
import json
home = os.path.expanduser("~")
class git_commands:
add = "git add -A"
commit = "git commit -m {}"
status = "git status"
push = "git push origin master"
Config = {
"BOOSTNOTE_PATH": "~/BoostNotes",
"SHIELDS": True,
"SHIELDS_TYPE": "for-the-badge",
"FREQUENCY": "hourly",
"TIME": 1200
}
def interactive():
conf = {}
questions = [
['BOOSTNOTE_PATH: ', ' ~/BoostNotes', 'BOOSTNOTE_PATH'],
['SHIELDS: ', ' True', 'SHIELDS'],
['SHIELDS_TYPE: ', 'for-the-badge', 'SHIELDS_TYPE'],
# ["hourly", "daily", "weekly", "monthly", "onchange"]
['FREQUENCY: ', 'hourly', 'FREQUENCY'],
['TIME: ', '1200', 'TIME'], # 24 gour format for now
]
for question in questions:
conf[question[2]] = input_with_prefill(question[0], question[1])
print(json.dumps(
conf, indent=2
))
return conf
def config_reader(location):
config = yaml.load(open(location), Loader=yaml.Loader)
print(json.dumps(config, indent=2))
return config
def input_with_prefill(prompt, text):
def hook():
readline.insert_text(text)
readline.redisplay()
readline.set_pre_input_hook(hook)
result = input(prompt)
readline.set_pre_input_hook()
return result
def create_config(location='.'):
'''
Creates a default config for users to see.
'''
yaml.dump(
Config,
open(os.path.join(location, 'bns.yaml'), 'w+')
)
# create_config()