add missing documentation
This commit is contained in:
parent
4ccd28f34d
commit
0d55bedc70
|
@ -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)
|
Reference in New Issue