diff options
-rw-r--r-- | ogcp/views.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index ae07f31..a2c4e9d 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -99,9 +99,6 @@ class ServerErrorCode(Exception): def normalize_mac(mac): return mac.replace(':', '').replace('-', '').replace('.', '').lower() -def prettify_mac(mac): - return (':'.join(mac[i:i+2] for i in range(0, 12, 2))).lower() - def is_valid_normalized_mac(mac): if len(mac) != 12: return False @@ -109,6 +106,13 @@ def is_valid_normalized_mac(mac): return False return True +def prettify_mac(mac): + normalized_mac = normalize_mac(mac) + + if not is_valid_normalized_mac(normalized_mac): + return mac + return (':'.join(normalized_mac[i:i+2] for i in range(0, 12, 2))).lower() + def ogserver_down(view): flash(_('Cannot talk to ogserver. Is ogserver down?'), category='error') return redirect(url_for(view)) |