def _parse_credentials(username, password, database, options):
 mechanism = options.get('authmechanism', 'DEFAULT')
 if ((username is None) and (mechanism != 'MONGODB-X509')):
  return None
 source = options.get('authsource', (database or 'admin'))
 return _build_credentials_tuple(mechanism, source, username, password, options)

def _parse_credentials ( username , password , database , options ) : mechanism = options . get ( 'authmechanism' , 'DEFAULT' ) if ( ( username is None ) and ( mechanism != 'MONGODB-X509' ) ) : return None source = options . get ( 'authsource' , ( database or 'admin' ) ) return _build_credentials_tuple ( mechanism , source , username , password , options )
parse authentication credentials .