def get_catalog_path(layer):
    """Get the catalog path for the designated layer if possible. Ensures we can pass map layers to the subprocess.

    If it's already a string, assume it's a catalog path and return it as is.

    Args:
        layer (layer object or string): Layer from which to retrieve the catalog path.

    Returns:
        string: Catalog path to the data
    """
    if hasattr(layer, "dataSource"):
        return layer.dataSource
    else:
        return layer