def main(argv): if len(argv) > 0: checkfile(argv[0]) rects = load_rect_from_path(argv[0]) else: rects = load_rect_from_file(sys.stdin) print rect_area(rects)
def main(args): checkfile(args.file0); checkfile(args.file1); rect_list_one = load_rect_from_path(args.file0) rect_list_second = load_rect_from_path(args.file1) intersections = [] for rect1 in rect_list_one: for rect2 in rect_list_second: rect = rect1.intersect(rect2) if rect.width > 0 and rect.height > 0: intersections.append(rect) if args.print_area: print('%d %d %d' % (rect_area(rect_list_one), rect_area(rect_list_second), rect_area(intersections))) else: for i in intersections: print i