|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
import re
|
|
|
|
|
import json
|
|
|
|
|
import hashlib
|
|
|
|
|
from enum import Enum, auto
|
|
|
|
|
from nag_object import NagObject, NagObjectType
|
|
|
|
|
|
|
|
|
@ -9,14 +11,22 @@ class ParserState(Enum):
|
|
|
|
|
DIRECTIVE = auto()
|
|
|
|
|
MULTILINE = auto()
|
|
|
|
|
|
|
|
|
|
def hash_string(string:str) -> int:
|
|
|
|
|
hash = hashlib.sha256()
|
|
|
|
|
hash.update(string.encode('utf-8'))
|
|
|
|
|
digest = hash.hexdigest()
|
|
|
|
|
return int(digest,16) * 1000000
|
|
|
|
|
|
|
|
|
|
class NagParse:
|
|
|
|
|
def __init__(self, config_files: list[str]):
|
|
|
|
|
self.m_config_files: list[str] = config_files
|
|
|
|
|
self.m_config_table: dict[int,str] = dict()
|
|
|
|
|
self.m_objects: list[NagObject] = list()
|
|
|
|
|
for config_file in self.m_config_files:
|
|
|
|
|
for config_file in self.m_config_files:
|
|
|
|
|
self.m_config_table[hash_string(config_file)] = config_file
|
|
|
|
|
for object in self.parse_config(config_file):
|
|
|
|
|
self.m_objects.append(object)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
string = str()
|
|
|
|
|
for object in self.m_objects:
|
|
|
|
|