From 89655373d4149a33c298c58aa1511168d6e86397 Mon Sep 17 00:00:00 2001 From: topilski Date: Tue, 30 Jan 2018 11:49:59 +0300 Subject: [PATCH] is_valid_email --- base/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base/utils.py b/base/utils.py index 70d67be..21d70ab 100644 --- a/base/utils.py +++ b/base/utils.py @@ -33,6 +33,13 @@ class CompileInfo(object): self.flags_.extend(other_args) +def is_valid_email(email: str) -> bool: + if not re.match('[^@]+@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', email): + return False + + return True + + def read_file_line_by_line_to_list(file) -> list: if not os.path.exists(file): raise BuildError('file path: {0} not exists'.format(file))