def chroot()

in faker_datasets/__init__.py [0:0]


def chroot(dataset, common_path, item_path=None):
    for part in common_path.split(".")[1:]:
        dataset = dataset[part]
    if item_path:
        item_path_parts = item_path.split(".")[1:]
        new_dataset = []
        for item in dataset:
            for part in item_path_parts:
                item = item[part]
            new_dataset.append(item)
        dataset = new_dataset
    return dataset