Return a dict with objects mapped by their id from a CSV endpoint

def _get_registry(self, registry_path_or_url):
        '''Return a dict with objects mapped by their id from a CSV endpoint'''
        if os.path.isfile(registry_path_or_url):
            with open(registry_path_or_url, 'r') as f:
                reader = compat.csv_dict_reader(f.readlines())
        else:
            res = requests.get(registry_path_or_url)
            res.raise_for_status()

            reader = compat.csv_dict_reader(StringIO(res.text))

        return dict([(o['id'], o) for o in reader])