Skip to content

Commit

Permalink
Squash the _validate_gateway_ip and __validate_ip function
Browse files Browse the repository at this point in the history
  • Loading branch information
seankingyang committed Oct 14, 2024
1 parent f9d1280 commit 256ef5c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions providers/base/bin/wifi_client_test_netplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,12 @@ def _validate_gateway_ip(gateway):
# Examples:
# 192.168.144.1 (TP-Link 123)
# 192.168.144.1
ip_part = gateway.split()[0] # Get the first part before any space
return ip_part if __validate_ip(ip_part) else ""


def __validate_ip(ip):
ip_address = gateway.split()[0] # Get the first part before any space
try:
ipaddress.ip_address(ip)
return True
ipaddress.ip_address(ip_address)
return ip_address
except ValueError:
return False
return ""


def get_gateway(interface, renderer):
Expand Down

0 comments on commit 256ef5c

Please sign in to comment.