line = line.replace('}', ']')
re_range = re.search('^(.*?)<(\d+-\d+)>(.*)$', line)
+ # A one off to handle "CMD_RANGE_STR(1, MULTIPATH_NUM)"
+ if 'CMD_RANGE_STR<' in line:
+ line = line.replace('CMD_RANGE_STR<', 'CMD_RANGE_STR(')
+ line = line.replace('>', ')')
+
while re_range:
line = "%s(%s)%s" % (re_range.group(1), re_range.group(2), re_range.group(3))
re_range = re.search('^(.*?)<(\d+-\d+)>(.*)$', line)
if not line.endswith('\n'):
line += '\n'
+ # compress duplicate whitespaces
+ re_space = re.search('^(\s*).*(\s*)$', line)
+ line = re_space.group(1) + ' '.join(line.split()) + re_space.group(2)
return line
def dump(self):
DEFUN (ip_route_mask_flags_tag_distance,
ip_route_mask_flags_tag_distance_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE> <reject|blackhole> tag (1-65535) (1-255)",
+ "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE> <reject|blackhole> tag (1-65535) (1-255)",
IP_STR
"Establish static routes\n"
"IP destination prefix\n"
DEFUN (ip_route_mask_flags_tag_distance_vrf,
ip_route_mask_flags_tag_distance_vrf_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE> <reject|blackhole> tag (1-65535) (1-255) " VRF_CMD_STR,
+ "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE> <reject|blackhole> tag (1-65535) (1-255) " VRF_CMD_STR,
IP_STR
"Establish static routes\n"
"IP destination prefix\n"
DEFUN (show_ip_route_vrf,
show_ip_route_vrf_cmd,
- "show ip route " VRF_CMD_STR " [json]",
+ "show ip route " VRF_CMD_STR " [json]",
SHOW_STR
IP_STR
"IP routing table\n"
DEFUN (show_ip_route_vrf_all_protocol,
show_ip_route_vrf_all_protocol_cmd,
- "show ip route " VRF_ALL_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA,
+ "show ip route " VRF_ALL_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA,
SHOW_STR
IP_STR
"IP routing table\n"
DEFUN (show_ip_route_vrf_all_addr,
show_ip_route_vrf_all_addr_cmd,
- "show ip route " VRF_ALL_CMD_STR " A.B.C.D",
+ "show ip route " VRF_ALL_CMD_STR " A.B.C.D",
SHOW_STR
IP_STR
"IP routing table\n"