Add type annotations

This commit is contained in:
David Mougeolle 2020-01-07 21:51:36 +01:00
parent e1af1f0a06
commit 8aeea6895e

View file

@ -42,18 +42,25 @@ def process(self):
results.append(host) results.append(host)
return results return results
class DnsReverse: class DnsReverse:
def __init__(self, iprange, verbose=False): def __init__(
self,
iprange: str,
verbose: bool = False) -> None:
self.iprange = iprange self.iprange = iprange
self.verbose = verbose self.verbose = verbose
def list(self): def list(
self) -> list:
prefix = '.'.join( prefix = '.'.join(
self.iprange.split('.')[:-1]) self.iprange.split('.')[:-1])
self.list = [prefix + '.' + str(i) for i in range(256)] self.list = [prefix + '.' + str(i) for i in range(256)]
def run(self, ip): def run(
self,
ip: str) -> str:
if self.verbose: if self.verbose:
esc = chr(27) esc = chr(27)
sys.stdout.write(esc + '[2K' + esc + '[G') sys.stdout.write(esc + '[2K' + esc + '[G')
@ -69,7 +76,8 @@ def run(self, ip):
except Exception: except Exception:
pass pass
def process(self): def process(
self) -> list:
results = [] results = []
for entry in self.list: for entry in self.list:
host = self.run(entry) host = self.run(entry)