Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ----- удалить завершенные файлы по времени -----
- timedict = {}
- datadict = {}
- error1 = error2 = False
- try:
- with open(path_for_queue+json_time_data) as ftd:
- timedict = json.load(ftd)
- except:
- error1 = True
- try:
- with open(path_for_queue+json_data) as fd:
- datadict = json.load(fd)
- except:
- error2 = False
- no_errors = (error1 == False and error2 == False)
- have_data = (len(timedict)>0 and len(datadict)>0)
- # удалить запись из основного словаря по временному словарю, где обработанные файлы
- if have_data and no_errors:
- with double_semaphore:
- for dc in timedict:
- for dc2 in datadict:
- if re.findall(dc, datadict[dc2]) and len(dc) > 0 and len(datadict[dc2]) > 0:
- del datadict[dc2]
- # перезапись словаря, если есть данные
- if len(datadict) > 0:
- with open(path_for_queue+json_data, "w") as fd:
- json.dump(datadict, fd, ensure_ascii=False, sort_keys=True, indent=4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement