Beispiel #1
0
    def get_crime_item(self):
        """ Return a Parse report.
            >>> report = Report(**{'date_type': 'test', 'location': 'capitol-hill', 'report_type': 'specific'})
            >>> output = report.get_crime_item()
            >>> print output['count'], output['crime']
            29 None
            """
        fn = self.build_filename()
        parse = Parse('_input/%s' % fn)
        parse.crime = self.crime
        parse.grep = self.grep
        try:
            parse.location = self.location
        except:
            pass
        try:
            parse.set_timespan(self.timespan)
        except:
            pass

        # *** eventually we might want to allow for other types of reports
        if self.report_type == 'rankings':
            result = parse.get_rankings()
        elif self.report_type == 'specific':
            result = parse.get_specific_crime()
        return result
Beispiel #2
0
def main(options, args):
    """ We run this when we run this script from the command line.
        >>> main(None, None)
        """
    parse = Parse('_input/test')
    parse.crime = 'violent'
    parse.grep = False
    parse.location = 'capitol-hill'
    result = parse.get_specific_crime()
    printcrimes = PrintCrimes(result, 'specific')
Beispiel #3
0
            print "We did not have any crimes to handle"
            outputs = ''

        if json_str is None:
            return outputs
        return json_str


if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option("-v", "--verbose", dest="verbose",
                      action="store_true", default=True)
    (options, args) = parser.parse_args()
    import doctest
    doctest.testmod(verbose=options.verbose)
    parse = Parse('_input/test')
    parse.crime = 'violent'
    parse.grep = False
    parse.location = 'capitol-hill'
    result = parse.get_specific_crime()
    printcrimes = PrintCrimes(result, 'specific')
    '''
    parse.set_grep(options.grep)
    limit = parse.set_limit(int(options.limit))
    crime = parse.set_crime(options.crime)
    location = parse.set_location(location)
    verbose = parse.set_verbose(options.verbose)
    address = parse.set_address(options.address)
    parse.set_diff(options.diff)
    '''