@classmethod
    def load(cls, builder_file, open=open):
        """
        Obtain RingBuilder instance of the provided builder file

        :param builder_file: path to builder file to load
        :return: RingBuilder instance
        """
        try:
            fp = open(builder_file, 'rb')
        except __HOLE__ as e:
            if e.errno == errno.ENOENT:
                raise exceptions.FileNotFoundError(
                    'Ring Builder file does not exist: %s' % builder_file)
            elif e.errno in [errno.EPERM, errno.EACCES]:
                raise exceptions.PermissionError(
                    'Ring Builder file cannot be accessed: %s' % builder_file)
            else:
                raise
        else:
            with fp:
                try:
                    builder = pickle.load(fp)
                except Exception:
                    # raise error during unpickling as UnPicklingError
                    raise exceptions.UnPicklingError(
                        'Ring Builder file is invalid: %s' % builder_file)

        if not hasattr(builder, 'devs'):
            builder_dict = builder
            builder = RingBuilder(1, 1, 1)
            builder.copy_from(builder_dict)
        for dev in builder.devs:
            # really old rings didn't have meta keys
            if dev and 'meta' not in dev:
                dev['meta'] = ''
            # NOTE(akscram): An old ring builder file don't contain
            #                replication parameters.
            if dev:
                if 'ip' in dev:
                    dev.setdefault('replication_ip', dev['ip'])
                if 'port' in dev:
                    dev.setdefault('replication_port', dev['port'])
        return builder
dataset/ETHPy150Open openstack/swift/swift/common/ring/builder.py/RingBuilder.load