-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain_validator.py
36 lines (27 loc) · 988 Bytes
/
domain_validator.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
34
35
36
"""
@author Merlin von der Weide
@version 1.0.0-beta
@date 30.07.2024
"""
import os
import sys
from validators import domain as validate_domain
from terminal_message_handler import print_error, print_warning
def validate_provided_domains(domains):
for domain in domains:
if not validate_domain(domain):
print_error("Invalid domain provided (%s)" % domain)
sys.exit(1)
def validate_args(args):
domain_arg_valid = args.domain is None or validate_domain(args.domain)
domain_file_arg_valid = args.domains_file is None or os.path.isfile(
args.domains_file)
if not domain_arg_valid:
print_warning("Domain is not valid. Is it formatted correctly?")
elif not domain_file_arg_valid:
print_warning("Domain file is not valid. Does it exist?")
valid_args = domain_arg_valid and domain_file_arg_valid
if not valid_args:
print_error("Arguments are invalid.")
sys.exit(1)
return valid_args