def determine_all_rates(upload, download):
tcp_all_rate = False # serves as flag too
udp_all_rate = False # serves as flag too
for groups in (upload, download):
if not groups:
continue
for group in groups:
# parsed = parse_branch(group)
parsed = BranchParser(group, dontcare=True).as_dict() # in this case we don't care for direction
if parsed['range'] == 'all' and parsed['protocol'] == 'tcp':
if tcp_all_rate:
raise ParserError("More than one 'all' range detected for the same protocol (tcp).")
tcp_all_rate = parsed['rate']
elif parsed['range'] == 'all' and parsed['protocol'] == 'udp':
if udp_all_rate:
raise ParserError("More than one 'all' range detected for the same protocol (udp).")
udp_all_rate = parsed['rate']
return tcp_all_rate, udp_all_rate
评论列表
文章目录