コード例 #1
0
    parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False)
    (options, args) = parser.parse_args()

    today = date.today()

    for item in report_items:
        if options.verbose == True:
            print item['name']
            print args
        item['date_type'] = options.date_type
        item['location'] = options.location
        item['report_type'] = options.report_type
        year = today.year
        #for yearback in [0, 1, 2, 3]:
        for yearback in [0, 1]:
            item['numago'] = yearback
            report = Report(*args, **item)

            # 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'] in ['rankings', 'specific']:
                if today.month == 1 and today.day < 21:
                    yearback += 1
                print '"%s__%d": ' % ( item['slug'], year - yearback ) 
                print report.get_crime_item(),
                print ","
            else:
                print report.get_crime_item()
コード例 #2
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)