本文整理汇总了Python中netman.regex.match函数的典型用法代码示例。如果您正苦于以下问题:Python match函数的具体用法?Python match怎么用?Python match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了match函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: resolve_port_mode
def resolve_port_mode(interface_data):
for line in interface_data:
if regex.match("switchport mode (\S+)", line):
return regex[0]
elif regex.match("switchport access vlan .*", line):
return "access"
return None
开发者ID:idjaw,项目名称:netman,代码行数:7,代码来源:dell.py
示例2: get_vlan
def get_vlan(self, number):
result = self.shell.do("show vlan id {}".format(number))
if regex.match(".*\^.*", result[0]):
raise BadVlanNumber()
elif regex.match("^ERROR", result[0]):
raise UnknownVlan(number)
else:
return parse_vlan_list(result)[0]
开发者ID:stephanerobert,项目名称:netman,代码行数:8,代码来源:dell10g.py
示例3: parse_interface_names
def parse_interface_names(self, status_list):
interfaces = []
for line in status_list:
if regex.match("(\d\S+).*", line):
interfaces.append("ethernet {}".format(regex[0]))
elif regex.match("ch(\d+).*", line):
interfaces.append("port-channel {}".format(regex[0]))
return interfaces
开发者ID:idjaw,项目名称:netman,代码行数:9,代码来源:dell.py
示例4: get_vlan
def get_vlan(self, vlan_number):
result = self.page_reader.do(self.shell, "show vlan id {}".format(vlan_number))
if regex.match(".*\^.*", result[0]):
raise BadVlanNumber()
elif regex.match("^ERROR", result[0]):
raise UnknownVlan(vlan_number)
vlan = parse_vlan_list(result)[0]
return vlan
开发者ID:internap,项目名称:netman,代码行数:9,代码来源:dell.py
示例5: get_vlan_interfaces
def get_vlan_interfaces(self, vlan_number):
result = self.shell.do("show vlan id {}".format(vlan_number))
if regex.match(".*\^.*", result[0]):
raise BadVlanNumber()
elif regex.match("^ERROR", result[0]):
raise UnknownVlan(vlan_number)
return self.parse_interface_from_vlan_list(vlan_number, result)
开发者ID:internap,项目名称:netman,代码行数:9,代码来源:dell10g.py
示例6: parse_interface_names
def parse_interface_names(status_list):
interfaces = []
for line in status_list:
if regex.match("Te(\d+/\d+/\S+).*", line):
interfaces.append("tengigabitethernet {}".format(regex[0]))
elif regex.match("Po(\d+).*", line):
interfaces.append("port-channel {}".format(regex[0]))
return interfaces
开发者ID:stephanerobert,项目名称:netman,代码行数:9,代码来源:dell10g.py
示例7: get_vlan_interfaces
def get_vlan_interfaces(self, vlan_number):
result = self.shell.do("show vlan id {}".format(vlan_number), wait_for=("--More-- or (q)uit", "#"), include_last_line=True)
while len(result) > 0 and "--More--" in result[-1]:
result += self.shell.send_key("m", wait_for=("--More-- or (q)uit", "#"), include_last_line=True)
if regex.match(".*\^.*", result[0]):
raise BadVlanNumber()
elif regex.match("^ERROR", result[0]):
raise UnknownVlan(vlan_number)
return self.parse_interface_from_vlan_list(vlan_number, result)
开发者ID:idjaw,项目名称:netman,代码行数:10,代码来源:dell.py
示例8: parse_vlan_list
def parse_vlan_list(result):
vlans = []
for line in result:
if regex.match("^(\d+)(.*)", line):
number, leftovers = regex
name = None
if regex.match("^\s{1,6}(\S+).*", leftovers):
name = regex[0]
vlan = Vlan(number=int(number), name=name if int(number) > 1 else "default")
vlans.append(vlan)
return vlans
开发者ID:internap,项目名称:netman,代码行数:11,代码来源:dell.py
示例9: parse_vlan_list
def parse_vlan_list(result):
vlans = []
for line in result:
if regex.match('^(\d+)\s{1,6}(\S+).*', line):
number, name = regex
vlans.append(Vlan(number=int(number),
name=name if int(number) > 1 else "default"))
elif regex.match('^(\d+)\s+.*', line):
number = regex[0]
vlans.append(Vlan(number=int(number)))
return vlans
开发者ID:godp1301,项目名称:netman,代码行数:11,代码来源:dell.py
示例10: test_should_be_threadsafe
def test_should_be_threadsafe(self):
regex.match('^(\w+)\s(\w+)$', 'hello world')
def match_single_word():
regex.match('^(\w+)$', 'bonjour')
assert_that(regex[0], is_('bonjour'))
t = Thread(target=match_single_word)
t.start()
t.join()
assert_that(regex[1], is_('world'))
开发者ID:stephanerobert,项目名称:netman,代码行数:12,代码来源:regex_facilitator_test.py
示例11: parse_vlan_list
def parse_vlan_list(result):
vlans = []
for line in result:
if regex.match("^(\d+)\s{1,6}(\S+).*", line):
number, name = regex
if name == "VLAN{:0>4}".format(number):
name = None
vlans.append(Vlan(number=int(number), name=name if int(number) > 1 else "default"))
elif regex.match("^(\d+)\s+.*", line):
number = regex[0]
vlans.append(Vlan(number=int(number)))
return vlans
开发者ID:godp1301,项目名称:netman,代码行数:12,代码来源:dell10g.py
示例12: parse_vlan_runningconfig
def parse_vlan_runningconfig(data):
vlan = {"tagged_interface": [], "untagged_interface": []}
if regex.match("^vlan (\d*)", data[0]):
vlan['id'] = int(regex[0])
for line in data:
if regex.match(" untagged (.*)", line):
for name in _to_real_names(parse_if_ranges(regex[0])):
vlan["untagged_interface"].append(name)
if regex.match(" tagged (.*)", line):
for name in _to_real_names(parse_if_ranges(regex[0])):
vlan["tagged_interface"].append(name)
return vlan
开发者ID:emmurd,项目名称:netman,代码行数:12,代码来源:brocade.py
示例13: parse_interface_from_vlan_list
def parse_interface_from_vlan_list(self, vlan_number, result):
vlan_interfaces = []
number = None
for line in result:
if regex.match('^(\d+)(.*)', line):
number, leftover = regex
if int(number) == vlan_number:
if regex.match('^\s{1,6}\S*\s+([a-zA-Z0-9-,/]+).*', leftover):
vlan_interfaces.extend(self.parse_interface_port_list(regex[0]))
elif regex.match('^\s+([a-zA-Z0-9-,/]+).*', line) and int(number) == vlan_number:
vlan_interfaces.extend(self.parse_interface_port_list(regex[0]))
return vlan_interfaces
开发者ID:idjaw,项目名称:netman,代码行数:14,代码来源:dell.py
示例14: add_vlan
def add_vlan(self, number, name=None):
result = self.shell.do("show vlan id {}".format(number))
if regex.match(".*\^.*", result[0]):
raise BadVlanNumber()
elif regex.match("^VLAN", result[0]):
raise VlanAlreadyExist(number)
with self.config():
with self.vlan_database():
self.set('vlan {}', number)
if name is not None:
with self.interface("vlan {}".format(number)):
self.set('name {}', name).on_any_result(BadVlanName)
开发者ID:idjaw,项目名称:netman,代码行数:14,代码来源:dell.py
示例15: parse_vlan
def parse_vlan(vlan_data):
regex.match("^vlan (\d+).*", vlan_data[0])
current_vlan = VlanBrocade(int(regex[0]))
if regex.match("^vlan \d+ name ([^\s]*)", vlan_data[0]):
current_vlan.name = regex[0] if regex[0] != "DEFAULT-VLAN" else "default"
else:
current_vlan.name = None
for line in vlan_data[1:]:
if regex.match("^\srouter-interface ve (\d+)", line):
current_vlan.vlan_interface_name = regex[0]
return current_vlan
开发者ID:emmurd,项目名称:netman,代码行数:14,代码来源:brocade.py
示例16: _get_vlan
def _get_vlan(self, vlan_number, include_vif_data=False):
result = self._show_vlan(vlan_number)
if result[0].startswith("Error"):
raise UnknownVlan(vlan_number)
vlan = VlanBrocade(vlan_number)
for line in result:
if regex.match(".*PORT-VLAN \d*, Name ([^,]+),.*", line):
vlan.name = regex[0] if regex[0] != "[None]" else None
vlan.name = vlan.name if vlan.name != "DEFAULT-VLAN" else "default"
elif regex.match(".*Associated Virtual Interface Id: (\d+).*", line):
vlan.vlan_interface_name = regex[0]
if include_vif_data:
add_interface_vlan_data(vlan, self.shell.do("show running-config interface ve {}".format(regex[0])))
return vlan
开发者ID:emmurd,项目名称:netman,代码行数:15,代码来源:brocade.py
示例17: parse_vlan_list
def parse_vlan_list(result):
vlans = []
for line in result:
if regex.match("^(\d+)(.*)", line):
number, leftovers = regex
name = None
if regex.match("^\s{1,6}(\S+)\s+([A-Za-z0-9-,/]+)", leftovers):
name, ports = regex
elif regex.match("^\s{1,6}(\S+).*", leftovers):
name = regex[0]
if name == "VLAN{:0>4}".format(number):
name = None
vlan = Vlan(number=int(number), name=name if int(number) > 1 else "default")
vlans.append(vlan)
return vlans
开发者ID:emmurd,项目名称:netman,代码行数:16,代码来源:dell10g.py
示例18: parse_if_ranges
def parse_if_ranges(string):
consumed_string = string.strip()
while len(consumed_string) > 0:
if regex.match("^(([^\s]*) ([^\s]*) to ([^\s]*)).*", consumed_string):
parsed_part, port_type, lower_bound, higher_bound = regex
lower_values = lower_bound.split("/")
higher_values = higher_bound.split("/")
for port_id in range(int(lower_values[-1]), int(higher_values[-1]) + 1):
yield "{} {}/{}".format(port_type, "/".join(lower_values[:-1]), port_id)
else:
regex.match("^([^\s]* [^\s]*).*", consumed_string)
parsed_part = regex[0]
yield regex[0]
consumed_string = consumed_string[len(parsed_part):].strip()
开发者ID:emmurd,项目名称:netman,代码行数:16,代码来源:brocade.py
示例19: read_interface
def read_interface(self, interface_name):
data = self.get_interface_data(interface_name)
interface = Interface(name=interface_name, port_mode=ACCESS, shutdown=False)
for line in data:
if regex.match("switchport mode \S+", line):
interface.port_mode = TRUNK
if regex.match("shutdown", line):
interface.shutdown = True
if regex.match("switchport access vlan (\d+)", line):
interface.access_vlan = int(regex[0])
if regex.match("switchport general pvid (\d+)", line):
interface.trunk_native_vlan = int(regex[0])
if regex.match("switchport \S* allowed vlan (add )?(\S+)", line):
interface.trunk_vlans = parse_vlan_ranges(regex[1])
return interface
开发者ID:stephanerobert,项目名称:netman,代码行数:17,代码来源:dell10g.py
示例20: parse_vlan
def parse_vlan(vlan_data):
regex.match("^vlan (\d+).*", vlan_data[0])
current_vlan = VlanBrocade(int(regex[0]))
if regex.match("^vlan \d+ name ([^\s]*)", vlan_data[0]):
current_vlan.name = regex[0] if regex[0] != "DEFAULT-VLAN" else "default"
else:
current_vlan.name = None
for line in vlan_data[1:]:
if regex.match("^\srouter-interface ve (\d+)", line):
current_vlan.vlan_interface_name = regex[0]
elif regex.match(" tagged (.*)", line):
for name in parse_if_ranges(regex[0]):
current_vlan.tagged_interfaces.append(name)
return current_vlan
开发者ID:godp1301,项目名称:netman,代码行数:17,代码来源:brocade.py
注:本文中的netman.regex.match函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论