#NEWLINE# def metrics( self , aliases , provider_url_template = None , cache_enabled = True , analytics_credentials = None ) : #NEWLINE# #INDENT# metrics = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# aliases_dict = provider . alias_dict_from_tuples ( aliases ) #NEWLINE# if ( 'blog' in aliases_dict ) : #NEWLINE# #INDENT# blog_url = aliases_dict [ 'blog' ] [ 0 ] #NEWLINE# url_override = ( self . metrics_url_template_public % provider . strip_leading_http ( blog_url ) . lower ( ) ) #NEWLINE# new_metrics = self . get_metrics_for_id ( blog_url , cache_enabled = cache_enabled , extract_metrics_method = self . _extract_metrics_subscribers , url_override = url_override ) #NEWLINE# metrics . update ( new_metrics ) #NEWLINE# #UNINDENT# if ( 'wordpress_blog_id' in aliases_dict ) : #NEWLINE# #INDENT# wordpress_blog_id = aliases_dict [ 'wordpress_blog_id' ] [ 0 ] #NEWLINE# url_override = ( self . metrics_url_template_comments % wordpress_blog_id ) #NEWLINE# new_metrics = self . get_metrics_for_id ( blog_url , cache_enabled = cache_enabled , extract_metrics_method = self . _extract_metrics_blog_comments , url_override = url_override ) #NEWLINE# metrics . update ( new_metrics ) #NEWLINE# #UNINDENT# if ( ( 'blog' in aliases_dict ) and analytics_credentials ) : #NEWLINE# #INDENT# blog_url = aliases_dict [ 'blog' ] [ 0 ] #NEWLINE# api_key = analytics_credentials [ 'wordpress_api_key' ] #NEWLINE# url_override = ( self . metrics_url_template_wordpress_blog_views % ( api_key , provider . strip_leading_http ( blog_url ) . lower ( ) ) ) #NEWLINE# new_metrics = self . get_metrics_for_id ( blog_url , cache_enabled = cache_enabled , extract_metrics_method = self . _extract_metrics_blog_views , url_override = url_override ) #NEWLINE# metrics . update ( new_metrics ) #NEWLINE# #UNINDENT# if ( 'wordpress_blog_post' in aliases_dict ) : #NEWLINE# #INDENT# nid = aliases_dict [ 'wordpress_blog_post' ] [ 0 ] #NEWLINE# post_id = self . wordpress_post_id_from_nid ( nid ) #NEWLINE# blog_url = self . blog_url_from_nid ( nid ) #NEWLINE# url_override = ( self . metrics_url_template_wordpress_post_comments % ( provider . strip_leading_http ( blog_url ) . lower ( ) , post_id ) ) #NEWLINE# new_metrics = self . get_metrics_for_id ( post_id , cache_enabled = cache_enabled , extract_metrics_method = self . _extract_metrics_post_comments , url_override = url_override ) #NEWLINE# metrics . update ( new_metrics ) #NEWLINE# if analytics_credentials : #NEWLINE# #INDENT# api_key = analytics_credentials [ 'wordpress_api_key' ] #NEWLINE# url_override = ( self . metrics_url_template_wordpress_post_views % ( api_key , provider . strip_leading_http ( blog_url ) . lower ( ) , post_id ) ) #NEWLINE# new_metrics = self . get_metrics_for_id ( blog_url , cache_enabled = cache_enabled , extract_metrics_method = self . _extract_metrics_blog_views , url_override = url_override ) #NEWLINE# metrics . update ( new_metrics ) #NEWLINE# #UNINDENT# #UNINDENT# metrics_and_drilldown = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for metric_name in metrics : #NEWLINE# #INDENT# drilldown_url = self . provenance_url ( metric_name , aliases ) #NEWLINE# metrics_and_drilldown [ metric_name ] = ( metrics [ metric_name ] , drilldown_url ) #NEWLINE# #UNINDENT# return metrics_and_drilldown