#NEWLINE# def diff( self , other_doc ) : #NEWLINE# #INDENT# "\n        Get the diff between two IndicatorDocuments. Assumes that the documents are of the same type and that\n        both have the same set of calculators and emitters. Doesn't support changes to group_by values.\n\n        Return value is None for no diff or a dict with all indicator values\n        that are different (added / removed / changed):\n            {\n                domains: ['domain1', 'domain2']\n                database: 'db1',\n                doc_type: 'MyIndicators',\n                group_names: ['domain', 'owner_id'],\n                group_values: ['test', 'abc']\n                indicator_changes: [\n                    {\n                    calculator: 'visit_week',\n                    emitter: 'all_visits',\n                    emitter_type: 'date',\n                    reduce_type: 'count',\n                    values: [\n                        {'date': '2012-09-23', 'value': 1, 'group_by': None},\n                        {'date': '2012-09-24', 'value': 1, 'group_by': None}\n                    ]},\n                    {\n                    calculator: 'visit_week',\n                    emitter: 'visit_hour',\n                    emitter_type: 'date',\n                    reduce_type: 'sum',\n                    values: [\n                        {'date': '2012-09-23', 'value': 8, 'group_by': None},\n                        {'date': '2012-09-24', 'value': 11, 'group_by': None}\n                    ]},\n                ],\n                all_indicators: [\n                    {\n                    calculator: 'visit_week',\n                    emitter: 'visit_hour',\n                    emitter_type: 'date',\n                    reduce_type: 'sum'\n                    },\n                    ....\n                ]\n\n            }\n        " #NEWLINE# diff_keys = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for calc_name in self . _calculators . keys ( ) : #NEWLINE# #INDENT# if other_doc : #NEWLINE# #INDENT# calc_diff = self . _shallow_dict_diff ( self [ calc_name ] , other_doc [ calc_name ] ) #NEWLINE# if calc_diff : #NEWLINE# #INDENT# diff_keys [ calc_name ] = calc_diff #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for ( emitter_name , values ) in self [ calc_name ] . items ( ) : #NEWLINE# #INDENT# if calc_diff : #NEWLINE# #INDENT# emitters = diff_keys . setdefault ( calc_name , [ ] ) #NEWLINE# emitters . append ( emitter_name ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( not diff_keys ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# diff = dict ( domains = list ( self . domains ) , database = self . Meta . app_label , doc_type = self . _doc_type , group_names = self . get_group_names ( ) , group_values = self . get_group_values ( ) , group_type_map = self . get_group_types ( ) , indicator_changes = [ ] , all_indicators = [ ] ) #NEWLINE# indicator_changes = diff [ 'indicator_changes' ] #NEWLINE# all_indicators = diff [ 'all_indicators' ] #NEWLINE# for ( calc_name , emitter_names ) in diff_keys . items ( ) : #NEWLINE# #INDENT# indicator_changes . extend ( self . _indicator_diff ( calc_name , emitter_names , other_doc ) ) #NEWLINE# #UNINDENT# for calc_name in self . _calculators . keys ( ) : #NEWLINE# #INDENT# for emitter_name in self [ calc_name ] . keys ( ) : #NEWLINE# #INDENT# all_indicators . append ( self . _indicator_meta ( calc_name , emitter_name ) ) #NEWLINE# #UNINDENT# #UNINDENT# return diff