-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessor.py
36 lines (31 loc) · 1.17 KB
/
processor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import crop
import re
class processor:
# This class concerns all processor functions
# Parent class for all the more specific processor classes
def __init__(self):
self.image_cropper = crop.crop() # Cropping tool
# Checks if a string has numbers
def hasnumbers(self, input):
return bool(re.search(r'\d', input))
# Checking for names
# Checking for all UPPER CASE words and obtaining name by process of elimination
def namevalidator(self, input):
# Ensuring that it is not PAN Number
if not self.hasnumbers(input):
return input
return False
# Checking output for PANNumber, returns the number if found
def pannumbervalidator(self, input):
regexmatch = re.search(r'[A-Z]{5}[0-9]{4}[A-Z]', input)
if regexmatch is not None:
return regexmatch.group()
else:
return False
# Checking output for Date of Birth, returns the number if found
def datevalidator(self, input):
regexmatch = re.search(r'\d{2}[-/]\d{2}[-/]\d{4}', input)
if regexmatch is not None:
return regexmatch.group()
else:
return False