def add_to_json(self,processed): # Load all matched grep. data = load_data() patt = re.compile('([^:]+):(\\d+):(.*)$') for line in processed.decode('utf-8').split('\n'): match = patt.match(line) if not match: continue data[line] = ([], []) save_data(data)
def to_json(self, processed): data = {} suspect = set() patt = re.compile('([^:]+):(\\d+):(.*)$') for line in processed.decode('utf-8').split('\n'): match = patt.match(line) if not match: continue data[line] = ([], []) # if old data exists, perform merge if data_exist(): old_data = load_data() data = merge(old_data, data) save_data(data)