-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncIP.py
More file actions
54 lines (49 loc) · 1.41 KB
/
Copy pathfuncIP.py
File metadata and controls
54 lines (49 loc) · 1.41 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#library IP
from urllib.request import Request
from urllib.request import urlopen
from time import clock
import xlrd
import re
import string
import recinFile
#IP or NOT IP
def isIp(ip):
log=True
octets = ip.split(".")
pattern = re.compile(r'\[a-z]')
if (isinstance(octets, int )==True): # True
for octet in octets:
if (255<int(octet) or int(octet)<0 or len(octets)!=4):
log = False
break
return log
#код прошел тестирование по наличию текстовых комбинаций в ячейке
def abcdIp(ip):
c = re.compile(r'\b^[a-z]')
tuples = re.findall(c, ip)
if tuples:
log=False
else:
log=True
return log
#код прошел тестирование по маске
def finditerIP(ip, namefileip):
#result = re.findall(c, ip)
#print(result)
#{[^}\n]+}
#result = re.finditer(r'[\d]+[.]+[\d]+[.]+[\d]+[.]+[\d]', ip)
result = re.finditer(r'[\d]+[.]+[\d]+[.]+[\d]+[.]+[\d]+', ip)
for match in result:
print(match.group())
recinFile.addinFile(namefileip, match)
# try:
#add ipdata in file
# f = open("ggg.txt", 'a')
# f.write(match.group()+"\n")
# f.close()
# except IOError:
# print ("No file")
# for match in result:
# print(match.group())
# log=True
#return log