Skip to content

Commit

Permalink
Allow comments in config files
Browse files Browse the repository at this point in the history
  • Loading branch information
GeeTransit committed Nov 21, 2020
1 parent 211b19e commit 29320b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ You can also run the following in case the program window closes immediately.

## Config

The *config.txt* file starts with the link to the Google Form (just copy from the address bar). The following lines have the following form:
The *config.txt* file starts with the link to the Google Form (just copy from the address bar).

The following lines contain info for each entry and the format is shown below. Empty lines and lines starting with `"#"` are skipped. Spaces between parts are ignored.

```
["*"] ["!"] type "-" key ";" [title] "=" [value]
Expand Down
2 changes: 2 additions & 0 deletions example.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
https://docs.google.com/forms/d/e/1FAIpQLSfWiBiihYkMJcZEAOE3POOKXDv6p4Ox4rX_ZRsQwu77aql8kQ/viewform

# This is the only prompt (helps identify responses)
! words - 2126808200 ; Short Answer = Default
words - 647036320 ; Paragraph = Sent using form.py (example-config.txt)
choice - 363426485 ; Multiple Choice (Option 1, Option 2) = Option 1
Expand Down
9 changes: 8 additions & 1 deletion form.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,14 @@ def open_config(file):
file = open(file)
with file:
url = to_form_url(file.readline())
entries = [EntryInfo.from_string(line) for line in file if line.strip()]
entries = []
for line in file:
line = line.strip()
if not line:
continue
if line.startswith("#"):
continue
entries.append(EntryInfo.from_string(line))
return ConfigInfo(url, entries)

# Returns the passed config file name
Expand Down

0 comments on commit 29320b6

Please sign in to comment.