Common: Do small style fixes in validators

This commit is contained in:
vakarisz 2022-08-01 16:54:28 +03:00
parent 42e6039463
commit 22b3874b5a
2 changed files with 7 additions and 10 deletions

View File

@ -13,12 +13,12 @@ def validate_linux_filename(linux_filename: str):
def validate_windows_filename(windows_filename: str):
validate_windows_filename_not_reserved(windows_filename)
_validate_windows_filename_not_reserved(windows_filename)
if not re.match(_valid_windows_filename_regex, windows_filename):
raise ValidationError(f"Invalid Windows filename {windows_filename}: illegal characters")
def validate_windows_filename_not_reserved(windows_filename: str):
def _validate_windows_filename_not_reserved(windows_filename: str):
# filename shouldn't start with any of these and be followed by a period
if PureWindowsPath(windows_filename).is_reserved():
raise ValidationError(f"Invalid Windows filename {windows_filename}: reserved name used")

View File

@ -52,15 +52,12 @@ def validate_ip_network(ip_network: str):
def validate_ip_range(ip_range: str):
try:
ip_range = ip_range.replace(" ", "")
ips = ip_range.split("-")
if len(ips) != 2:
raise ValidationError(f"Invalid IP range {ip_range}")
validate_ip(ips[0])
validate_ip(ips[1])
except IndexError:
raise ValidationError(f"Invalid IP range {ip_range}")
def validate_ip(ip: str):