-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathutils.py
More file actions
35 lines (28 loc) · 909 Bytes
/
utils.py
File metadata and controls
35 lines (28 loc) · 909 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
import yaml
def input_options(prompt, options):
print(prompt)
print("Valid Options:")
for o in options:
print(f" {o}")
selected_option = input()
while selected_option not in options:
print("Invalid option, please try again.")
selected_option = input(":")
return selected_option
def load_jeykll_config(path="_config.yml"):
with open(path) as stream:
try:
return (yaml.safe_load(stream))
except yaml.YAMLError as exc:
print(exc)
def dump_dict_to_yaml(data, out_dest):
out_file = open(out_dest, "w")
out_file.write("---\n")
yaml.dump(data, out_file, allow_unicode=True)
out_file.write("---")
def y_or_n(prompt):
response = input(prompt + "[y/n]:")
while response not in ["y", "n"]:
print("Invalid response")
response = input(prompt + "[y/n]:")
return response == "y"