1
0
Fork 0

add missing documentation

This commit is contained in:
Lili (Tlapka) 2021-05-28 12:09:46 +02:00
parent 4ccd28f34d
commit 0d55bedc70
1 changed files with 8 additions and 0 deletions

View File

@ -1,15 +1,22 @@
import yaml
class FlagChecker:
"""Class that checks if flags are correct, and also remembers wrong flags.
Needs a file with the flags to levels written in."""
def __init__(self, filename):
self.wrong_flags = {}
self.read_keys(filename)
def read_keys(self, filename):
"""Reads levels and flags from file `filename`"""
with open(filename) as f:
self.flags = yaml.load(f, Loader=yaml.FullLoader)
def check_flag(self, level, flag):
"""Checks if `flag` is a correct flag for `level`.
If it isn't, it adds `flag` to the list of incorrect flags."""
if self.flags[level] == flag:
return True
else:
@ -19,5 +26,6 @@ class FlagChecker:
return False
def log_to_file(self, filename):
"""Logs everything to a file."""
with open(filename, 'a') as f:
yaml.dump(self.wrong_flags, f)