コード例 #1
0
ファイル: monthly.py プロジェクト: freejoe76/crime
    #parser.add_option("-c", "--crime", dest="crime", default=None)
    parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False)
    (options, args) = parser.parse_args()

    for item in report_items:
        if options.verbose == True:
            print item['name']
        item['date_type'] = options.date_type
        item['location'] = options.location
        item['report_type'] = options.report_type
        year = date.today().year
        month = date.today().month
        ym = '%d%d' % (year, month)
        if month < 10:
            ym = '%d0%d' % (year, month)

        for ago in range(24):
            item['numago'] = ago 
            report = Report(*args, **item)
            report.set_timespan('', ago)
            # Rankings output comes default in specific report,
            # so if we're specifying rankings as the report_type that means
            # we're using this output for something else... something else that
            # needs it in ready-to-write-the-compiled-json-to-a-file format.
            if item['report_type'] == 'rankings':
                print '"%s__%d": ' % ( item['slug'], int(ym) ) 
                print '%s,' % json.dumps(report.get_crime_item()),
            else:
                print report.get_crime_item()
            ym = yearmonth_subtract(ym)