-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparseit.py
More file actions
27 lines (23 loc) · 707 Bytes
/
parseit.py
File metadata and controls
27 lines (23 loc) · 707 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
import re
# Parsing of some standart things
def parse_int_name(string):
# Interface name parsing
ciscoIntRegex = re.compile(r'(Gi|Te|Fa|Tu|Eth|Po|Port-channel|e|Null|Vlan|Serial|Bundle-Ether)[a-zA-Z*]?[-]?[a-zA-Z*]?\d+(([\/\.:]\d+)+(\.\d+)?)?')
mo=ciscoIntRegex.search(string)
if mo:
result = mo.group()
return result
else:
return Exception
def parse_dev_name(string):
# Device name parsing
ciscoIntRegex = re.compile(r'\w{4,}[a-zA-Z0-9_\.]*\d\d?')
mo=ciscoIntRegex.search(string)
if mo:
result = mo.group()
return result
else:
if string:
return string
else:
return 'UNKNOWN_NAME'