Duplicate hosts are now omitted

This commit is contained in:
slashtechno 2023-08-18 20:51:00 -04:00
parent 255994447a
commit 7e98125597
Signed by: slashtechno
GPG Key ID: 8EC1D9D9286C2B17
2 changed files with 6 additions and 5 deletions

View File

@ -95,7 +95,7 @@ def main():
logger.info("No credentials provided with flags")
if Path(".env").is_file():
logger.debug("Loading .env")
dotenv.load_dotenv()
dotenv.load_dotenv(Path(Path.cwd() / ".env"))
else:
logger.debug("No .env file found")
try:
@ -106,7 +106,8 @@ def main():
logger.error("No credentials provided")
argparser.print_help()
exit(1)
# For debugging, print cwd
logger.debug(f"Current working directory: {Path.cwd()}")
try:
args.func(args)
except AttributeError:

View File

@ -73,13 +73,13 @@ def convert_to_list(file: pathlib.Path) -> list:
re.search(r"^(?:127\.0\.0\.1|0\.0\.0\.0|::1)\s+(.+?)(?:\s+#.+)?$", line)
for line in f
]
hosts = [
hosts = {
match.group(1)
for match in matches
if match and match.group(1) not in loopback
]
}
# print(f"First 5 hosts: {hosts[:5]}")
return hosts
return list(hosts)
# General Utils