diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-05-06 16:45:44 +0100 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-05-06 16:45:44 +0100 |
commit | 3639a5610b590a64d6d56bee81dddd252994cfe5 (patch) | |
tree | bffd67c3bc929523e99ab3ad3c11097bbffc5d8d /src/validators/mac-address | |
parent | 142a6b99f0da5cf474f03572e1e6c2f8772c77c9 (diff) | |
download | vyos-1x-3639a5610b590a64d6d56bee81dddd252994cfe5.tar.gz vyos-1x-3639a5610b590a64d6d56bee81dddd252994cfe5.zip |
validator: T2417: try to make the code clearer
Diffstat (limited to 'src/validators/mac-address')
-rwxr-xr-x | src/validators/mac-address | 17 |
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) |