confighelper: add get_hash method
This returns the checksum of a config section and can be used to check if the section has changed. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
eda5623b2e
commit
f7bdfb4d6b
|
@ -7,6 +7,7 @@
|
|||
from __future__ import annotations
|
||||
import configparser
|
||||
import os
|
||||
import hashlib
|
||||
from utils import SentinelClass
|
||||
from components.gpio import GpioOutputPin
|
||||
|
||||
|
@ -73,6 +74,12 @@ class ConfigHelper:
|
|||
def get_options(self) -> Dict[str, str]:
|
||||
return dict(self.config[self.section])
|
||||
|
||||
def get_hash(self) -> hashlib._Hash:
|
||||
hash = hashlib.sha256()
|
||||
for option in self.config[self.section]:
|
||||
hash.update(option.encode())
|
||||
return hash
|
||||
|
||||
def get_prefix_sections(self, prefix: str) -> List[str]:
|
||||
return [s for s in self.sections() if s.startswith(prefix)]
|
||||
|
||||
|
|
Loading…
Reference in New Issue