-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindMissingFileNumbers_10000.py
38 lines (33 loc) · 1.25 KB
/
FindMissingFileNumbers_10000.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
#! /usr/bin/env/python
import mmap
import re
#-------------------------------------------------------------------------------------------
# Main Function
#-------------------------------------------------------------------------------------------
def main():
filePath = input("Enter file path: ")
endFileNum = input("Enter end file number: ")
print(filePath)
print(endFileNum)
filesMissing = []
filesPresent = []
f = open(filePath, 'rb', 0)
s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
#>>> myRegex=r'(.*)file_(.)' + re.escape(str(TEXTTO)) + r'\.txt'
#>>> searchObj=re.search(myRegex,line)
#>>> print(searchObj)
#<_sre.SRE_Match object; span=(0, 15), match='asdffile__0.txt'>
for x in range(int(endFileNum)):
myRegex = r'(.*)file(.*)' + re.escape(str(x)) + r'\.txt'
myRegex = bytes(myRegex, 'utf-8')
if re.search(myRegex, s):
filesPresent.append(x)
else:
filesMissing.append(x)
print(filesPresent)
print(filesMissing)
#-------------------------------------------------------------------------------------------
# Start Main
#-------------------------------------------------------------------------------------------
if __name__ == "__main__":
main()