-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherrorCheck.py
39 lines (31 loc) · 973 Bytes
/
errorCheck.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
37
38
39
'''
This class is implemented for basic input validation, to check if the input is
not as expected.
Currently implements two cases:
1. isEnglish: True if input is in english. Transliteration is from native script to roman and not other way round.
2. isEmpty: if no input is given.
'''
class errorCheck:
def __init__(self,input):
self.input = str(input)
def isEnglish(self):
input = self.input
try:
input.encode('ascii')
except UnicodeEncodeError:
input.encode('utf-8')
return False
else:
return True
def isEmpty(self):
if(not (self.input and self.input.strip())):
return True
else:
return None
def CheckInput(self):
if(self.isEmpty()):
return "Please provide input."
elif(self.isEnglish()):
return "Please do not provide input in English."
else:
return False