add missing documentation
This commit is contained in:
parent
4ccd28f34d
commit
0d55bedc70
|
@ -1,15 +1,22 @@
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
class FlagChecker:
|
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):
|
def __init__(self, filename):
|
||||||
self.wrong_flags = {}
|
self.wrong_flags = {}
|
||||||
self.read_keys(filename)
|
self.read_keys(filename)
|
||||||
|
|
||||||
def read_keys(self, filename):
|
def read_keys(self, filename):
|
||||||
|
"""Reads levels and flags from file `filename`"""
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
self.flags = yaml.load(f, Loader=yaml.FullLoader)
|
self.flags = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
def check_flag(self, level, flag):
|
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:
|
if self.flags[level] == flag:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
@ -19,5 +26,6 @@ class FlagChecker:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def log_to_file(self, filename):
|
def log_to_file(self, filename):
|
||||||
|
"""Logs everything to a file."""
|
||||||
with open(filename, 'a') as f:
|
with open(filename, 'a') as f:
|
||||||
yaml.dump(self.wrong_flags, f)
|
yaml.dump(self.wrong_flags, f)
|
Reference in New Issue