if the question starts on line 4 of the program, the for loop is followed by if judgment, and then name=self._nic_ovs_name_pattern.search (o) refers to the if conditional judgment returns true before the assignment operation is performed? Or is it executed when if returns False? When the return ovs_nics, of the last line is met, what conditions are returned? The overall execution order of this function is not very clear, please give me some advice, thank you.
def __extract_ovs_nic_detail(self, output):
ovs_nics = []
ovs_nic = {}
for o in output.split("\n"):
if "_uuid : " in o:
ovs_nic = {}
name = self._nic_ovs_name_pattern.search(o)
if not name is None:
ovs_nic["name"] = name.group(2).strip("\"")
mac = self._nic_ovs_mac_pattern.search(o)
if not mac is None:
ovs_nic["mac"] = mac.group(2).strip("\"")
mtu = self._nic_ovs_mtu_pattern.search(o)
if not mtu is None:
ovs_nic["mtu"] = mtu.group(2)
speed = self._nic_ovs_speed_pattern.search(o)
if not speed is None:
ovs_nic["speed"] = str(int(speed.group(2)) / 1000000) + "Mb/s"
if "type : " in o:
ovs_nics.append(ovs_nic)
return ovs_nics