flag checker implementation
This commit is contained in:
parent
30769aa454
commit
d18ef13d6d
|
@ -0,0 +1,23 @@
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
class FlagChecker:
|
||||||
|
def __init__(self, filename):
|
||||||
|
self.wrong_flags = {}
|
||||||
|
self.read_keys(filename)
|
||||||
|
|
||||||
|
def read_keys(self, filename):
|
||||||
|
with open(filename) as f:
|
||||||
|
self.flags = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
def check_flag(self, level, flag):
|
||||||
|
if self.flags[level] == flag:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
if not level in self.wrong_flags:
|
||||||
|
self.wrong_flags[level] = []
|
||||||
|
self.wrong_flags[level].append(flag)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def log_to_file(self, filename):
|
||||||
|
with open(filename, 'a') as f:
|
||||||
|
yaml.dump(self.wrong_flags, f)
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
level1: "Sherlock"
|
||||||
|
level2: "NAKA_is_watching_you"
|
||||||
|
level3: "CrazyHacker"
|
||||||
|
level4: "KimPutin"
|
||||||
|
level5: "RandomWordGenerator"
|
||||||
|
...
|
Reference in New Issue