#NEWLINE# def load_config( root = None ) : #NEWLINE# #INDENT# root = ( root or os . environ [ 'HOME' ] ) #NEWLINE# config = { #NEWLINE# #INDENT# 'Configs' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'rootPath' : root , #NEWLINE# #UNINDENT# } #NEWLINE# config_file = os . path . join ( root , '.dockercfg' ) #NEWLINE# if ( not os . path . exists ( config_file ) ) : #NEWLINE# #INDENT# return config #NEWLINE# #UNINDENT# with open ( config_file ) as f : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# config [ 'Configs' ] = json . load ( f ) #NEWLINE# for ( k , conf ) in six . iteritems ( config [ 'Configs' ] ) : #NEWLINE# #INDENT# ( conf [ 'Username' ] , conf [ 'Password' ] ) = decode_auth ( conf [ 'auth' ] ) #NEWLINE# del conf [ 'auth' ] #NEWLINE# config [ 'Configs' ] [ k ] = buf #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# f . seek ( 0 ) #NEWLINE# buf = [ ] #NEWLINE# for line in f : #NEWLINE# #INDENT# ( k , v ) = line . split ( ' = ' ) #NEWLINE# buf . append ( v ) #NEWLINE# #UNINDENT# if ( len ( buf ) < 2 ) : #NEWLINE# #INDENT# raise Exception ( 'The Auth config file is empty' ) #NEWLINE# #UNINDENT# ( user , pwd ) = decode_auth ( buf [ 0 ] ) #NEWLINE# config [ 'Configs' ] [ INDEX_URL ] = { #NEWLINE# #INDENT# 'Username' : user , #NEWLINE# 'Password' : pwd , #NEWLINE# 'Email' : buf [ 1 ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# return config