-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
40 lines (30 loc) · 913 Bytes
/
utils.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
40
def get_text(data):
index = 0
final_text = ''
while index < len(data):
final_text += data[index]
index = index + 1
return final_text.replace("\t","").replace(" ", "").replace("--", "")
def to_int(str):
try:
return int(str)
except:
return None
def match_substring_recursive(needle, haystack):
if isinstance(haystack, str):
return needle in haystack
else:
return any(match_substring_recursive(needle, x) for x in haystack)
def find_index_sub_string(needle, haystack):
return [i for i, x in enumerate(haystack) if match_substring_recursive(needle, x)]
def subarray_exist(arr, index_array):
try:
temp = arr
for index in index_array:
if len(temp) > index:
temp = temp[index]
else:
return False
return True
except:
return False