def parse_ignore_range(string):
m = re.match(r"(\d+)(?:-(\d+))?$", string)
if not m:
raise argparse.ArgumentTypeError("'" + string + "' is not a range of number.")
start = min(int(m.group(1)), int(m.group(2)))
end = max(int(m.group(1)), int(m.group(2))) or start
if end > (128 << 10):
raise argparse.ArgumentTypeError("Value out of range (max 128KB).")
if start == 0 and end == (128 << 10):
raise argparse.ArgumentTypeError("Invalid range specified.")
return list([start, end])
评论列表
文章目录