summaryrefslogtreecommitdiff
path: root/src/validators/mac-address
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-08 20:27:31 +0200
committerGitHub <noreply@github.com>2020-05-08 20:27:31 +0200
commit2f2b28347b9a90953ff2419c03e8e02eab533f45 (patch)
treea5169f3fe6b53386ab93e8fefd5d4b920028506e /src/validators/mac-address
parent2c69daf94cbe9caf177af8959936917bdc645876 (diff)
parentff58182904882278a004f4d3d8082ec11adbe1ea (diff)
downloadvyos-1x-2f2b28347b9a90953ff2419c03e8e02eab533f45.tar.gz
vyos-1x-2f2b28347b9a90953ff2419c03e8e02eab533f45.zip
Merge pull request #395 from thomas-mangin/T2417
validator: T2417: try to make the code clearer
Diffstat (limited to 'src/validators/mac-address')
-rwxr-xr-xsrc/validators/mac-address17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/validators/mac-address b/src/validators/mac-address
index 435920b84..b2d3496f4 100755
--- a/src/validators/mac-address
+++ b/src/validators/mac-address
@@ -15,12 +15,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
-from sys import exit, argv
+import sys
-if len(argv) == 2:
- pattern = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$"
- if re.match(pattern, argv[1]):
- exit(0)
- else:
- exit(1)
+pattern = "^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$"
+
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ sys.exit(1)
+ if not re.match(pattern, sys.argv[1]):
+ sys.exit(1)
+ sys.exit(0)