#NEWLINE# def get_config( config_key , as_bool = False , default = None ) : #NEWLINE# #INDENT# '\n    Retrieves the value of pygithooks.<config_key> from git config, optionally forcing to be boolean.\n    ' #NEWLINE# git_config_command = ( 'git config --null %(bool_flag)s --get pygithooks.%(config_key)s' % dict ( config_key = config_key , bool_flag = ( '--bool' if as_bool else '' ) ) ) #NEWLINE# ( git_out , git_err , git_rc ) = run_command ( git_config_command ) #NEWLINE# if git_err : #NEWLINE# #INDENT# raise RuntimeError ( 'git config command returned an error' , git_config_command , git_err ) #NEWLINE# #UNINDENT# if ( ( not git_out ) or git_rc ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# null_index = git_out . find ( chr ( 0 ) ) #NEWLINE# if ( null_index < 0 ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# config_val = git_out [ : null_index ] #NEWLINE# if as_bool : #NEWLINE# #INDENT# return ( config_val == 'true' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return config_val