summaryrefslogtreecommitdiff
path: root/src/validators/fqdn
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-05-06 16:45:44 +0100
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-05-06 16:45:44 +0100
commit3639a5610b590a64d6d56bee81dddd252994cfe5 (patch)
treebffd67c3bc929523e99ab3ad3c11097bbffc5d8d /src/validators/fqdn
parent142a6b99f0da5cf474f03572e1e6c2f8772c77c9 (diff)
downloadvyos-1x-3639a5610b590a64d6d56bee81dddd252994cfe5.tar.gz
vyos-1x-3639a5610b590a64d6d56bee81dddd252994cfe5.zip
validator: T2417: try to make the code clearer
Diffstat (limited to 'src/validators/fqdn')
-rwxr-xr-xsrc/validators/fqdn21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/validators/fqdn b/src/validators/fqdn
index 9f4ed764f..347ffda42 100755
--- a/src/validators/fqdn
+++ b/src/validators/fqdn
@@ -14,14 +14,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from re import match
-from sys import argv,exit
+import re
+import sys
-if len(argv) == 2:
- # pattern copied from: https://www.regextester.com/103452
- pattern = "(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)"
- if match(pattern, argv[1]):
- exit(0)
- else:
- exit(1)
+# pattern copied from: https://www.regextester.com/103452
+pattern = "(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)"
+
+
+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)