-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathv6compress.py
More file actions
41 lines (28 loc) · 890 Bytes
/
v6compress.py
File metadata and controls
41 lines (28 loc) · 890 Bytes
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
#!/usr/bin/env python3
#compress v6 expanded addresses in bulk. pulls from a local file and based on python3
import ipaddress
import sys
with open('<file>') as mas:
v6 = mas.read().splitlines() #remove newline \n
for i in v6:
hey = ipaddress.ip_address(i)
print(hey.compressed)
####cleaner way to do it with user defining the file
#!/usr/bin/env python3
#compress v6 expanded addresses in bulk. pulls from a local file and based on python3
import ipaddress
import sys
menu= input("Enter 1 for v6 compression: ")
menu1 = int(menu)
if menu1 == 1:
getme = input("filename: ")
def v6compress(m):
i=m
with open(i) as mas:
v6 = mas.read().splitlines()
for i in v6:
hey = ipaddress.ip_address(i)
print(hey.compressed)
v6compress(getme)
else:
print ("nothing to do")