def report(self):
output = OrderedDict()<EOL>for arg in GLOBAL_ARGUMENTS:<EOL><INDENT>output[arg] = getattr(self.args, arg) or self.config.get(arg, None)<EOL><DEDENT>output['<STR_LIT:title>'] = getattr(self.args, '<STR_LIT:title>') or self.config.get('<STR_LIT:title>', '<STR_LIT>')<EOL>output['<STR_LIT>'] = datetime.now().strftime('<STR_LIT>')<EOL>output['<STR_LIT>'] = []<EOL>for analytic in self.config.get('<STR_LIT>', []):<EOL><INDENT>print('<STR_LIT>' % analytic['<STR_LIT:name>'])<EOL>results = self.query(<EOL>metrics=analytic['<STR_LIT>'],<EOL>dimensions=analytic.get('<STR_LIT>', []),<EOL>filters=analytic.get('<STR_LIT>', None),<EOL>segment=analytic.get('<STR_LIT>', None),<EOL>sort=analytic.get('<STR_LIT>', []),<EOL>start_index=analytic.get('<STR_LIT>', <NUM_LIT:1>),<EOL>max_results=analytic.get('<STR_LIT>', <NUM_LIT:10>)<EOL>)<EOL>dimensions_len = len(analytic.get('<STR_LIT>', []))<EOL>data = OrderedDict([ <EOL>('<STR_LIT>', analytic),<EOL>('<STR_LIT>', results.get('<STR_LIT>', False)),<EOL>('<STR_LIT>', int(results.get('<STR_LIT>', <NUM_LIT:0>))),<EOL>('<STR_LIT>', int(results.get('<STR_LIT>', <NUM_LIT:0>))),<EOL>('<STR_LIT>', OrderedDict()),<EOL>('<STR_LIT:data>', OrderedDict())<EOL>])<EOL>for column in results['<STR_LIT>'][dimensions_len:]:<EOL><INDENT>data['<STR_LIT>'][column['<STR_LIT:name>']] = column['<STR_LIT>']<EOL><DEDENT>def cast_data_type(d, dt):<EOL><INDENT>if dt == '<STR_LIT>':<EOL><INDENT>return int(d)<EOL><DEDENT>elif data_type in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:  <EOL><INDENT>return float(d)<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>' % data_type)<EOL><DEDENT><DEDENT>for i, metric in enumerate(analytic['<STR_LIT>']):<EOL><INDENT>data['<STR_LIT:data>'][metric] = OrderedDict()<EOL>data_type = data['<STR_LIT>'][metric]<EOL>if dimensions_len:<EOL><INDENT>for row in results.get('<STR_LIT>', []):<EOL><INDENT>column = i + dimensions_len<EOL>label = '<STR_LIT:U+002C>'.join(row[:dimensions_len]) <EOL>value = cast_data_type(row[column], data_type)<EOL>data['<STR_LIT:data>'][metric][label] = value <EOL><DEDENT><DEDENT>data['<STR_LIT:data>'][metric]['<STR_LIT>'] = cast_data_type(results['<STR_LIT>'][metric], data_type)<EOL>sleep(<NUM_LIT:1>)<EOL><DEDENT>output['<STR_LIT>'].append(data)<EOL><DEDENT>return output<EOL>
Query analytics and stash data in a format suitable for serializing.