-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindings.py
33 lines (27 loc) · 895 Bytes
/
findings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from io import TextIOWrapper
from logger import Logger
class Findings:
def __init__(self, log: Logger, free_file: TextIOWrapper, occu_file: TextIOWrapper) -> None:
self.log = log
self.free_file = free_file
self.occu_file = occu_file
self.occu = set()
self.free = set()
def persist(self):
for item in self.occu:
self.occu_file.write('{}\n'.format(item))
self.occu = set()
for item in self.free:
self.free_file.write('{}\n'.format(item))
self.free = set()
def add_domain(self, domain, is_free=False):
if is_free:
self.log.free(domain)
self.free.add(domain)
else:
self.log.occu(domain)
self.occu.add(domain)
def __del__(self):
self.persist()
self.occu_file.close()
self.free_file.close()