2021-06-25 18:55:15 +01:00
#!/usr/bin/env python3
2021-06-25 04:52:22 +01:00
### Script for adding a new category. Handles adding data to config.csv.
from utils import csv as util_csv
divider = " ---------- "
2021-06-26 04:24:31 +01:00
print ( f " \n We ' ll ask for the name and rules of the new category. \n \n { divider } \n " )
2021-06-25 04:52:22 +01:00
2021-06-26 04:59:37 +01:00
tk_category_name = input ( " Name: " ) . replace ( ' " ' , " " )
tk_category_rules = input ( " Rules: " ) . replace ( ' " ' , " " )
2021-06-25 04:52:22 +01:00
2021-06-26 04:40:11 +01:00
tk_category_dashname = tk_category_name . replace ( " " , " _ " ) . replace ( " % " , " " )
2021-06-25 04:52:22 +01:00
categoryDict = {
" tk_category_dashname " : tk_category_dashname ,
2021-06-25 18:35:35 +01:00
" tk_category_name " : tk_category_name ,
2021-06-25 04:52:22 +01:00
" tk_category_rules " : tk_category_rules ,
}
2021-06-25 18:35:35 +01:00
util_csv . dictWriter ( " ../csv/categories.csv " , categoryDict , " a " )
2021-06-25 04:52:22 +01:00
print (
f " \n { divider } \n \n Added category! If you made a mistake, you can manually edit csv/categories.csv (and csv/runs.csv if you ' ve added any runs to the borked category). \n "
)