#NEWLINE# @ classmethod #NEWLINE# def load( cls , builder_file , open = open ) : #NEWLINE# #INDENT# '\n        Obtain RingBuilder instance of the provided builder file\n\n        :param builder_file: path to builder file to load\n        :return: RingBuilder instance\n        ' #NEWLINE# try : #NEWLINE# #INDENT# fp = open ( builder_file , 'rb' ) #NEWLINE# #UNINDENT# except IOError as e : #NEWLINE# #INDENT# if ( e . errno == errno . ENOENT ) : #NEWLINE# #INDENT# raise exceptions . FileNotFoundError ( ( 'Ring Builder file does not exist: %s' % builder_file ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( e . errno in [ errno . EPERM , errno . EACCES ] ) : #NEWLINE# #INDENT# raise exceptions . PermissionError ( ( 'Ring Builder file cannot be accessed: %s' % builder_file ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# with fp : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# builder = pickle . load ( fp ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# raise exceptions . UnPicklingError ( ( 'Ring Builder file is invalid: %s' % builder_file ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not hasattr ( builder , 'devs' ) ) : #NEWLINE# #INDENT# builder_dict = builder #NEWLINE# builder = RingBuilder ( 1 , 1 , 1 ) #NEWLINE# builder . copy_from ( builder_dict ) #NEWLINE# #UNINDENT# for dev in builder . devs : #NEWLINE# #INDENT# if ( dev and ( 'meta' not in dev ) ) : #NEWLINE# #INDENT# dev [ 'meta' ] = '' #NEWLINE# #UNINDENT# if dev : #NEWLINE# #INDENT# if ( 'ip' in dev ) : #NEWLINE# #INDENT# dev . setdefault ( 'replication_ip' , dev [ 'ip' ] ) #NEWLINE# #UNINDENT# if ( 'port' in dev ) : #NEWLINE# #INDENT# dev . setdefault ( 'replication_port' , dev [ 'port' ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return dev