Takes a geometry string, returns map of parameters.

def parse_geometry(geometry):
    """Takes a geometry string, returns map of parameters."""

    m = re.match("(\d+)x(\d+)([-+]\d+)([-+]\d+)", geometry)
    if not m:
        raise ValueError("failed to parse geometry string")
    return map(int, m.groups())