def unpack_polygons(polygons: Sequence[Polygon], context: Context) -> Union[Empty, Multipolygon, Polygon]: return ((context.multipolygon_cls(polygons) if len(polygons) > 1 else polygons[0]) if polygons else context.empty)
def unpack_regions(regions: Sequence[Contour], context: Context) -> Union[Empty, Polygon, Multipolygon]: polygon_cls = context.polygon_cls return ((context.multipolygon_cls([polygon_cls(region, []) for region in regions]) if len(regions) > 1 else polygon_cls(regions[0], [])) if regions else context.empty)