def run(options):
    year_range = inspector.year_range(options)
    report_id = options.get('report_id')
    for year in year_range:
        url = audit_url_for(year)
        doc = beautifulsoup_from_url(url)
        agency_tables = doc.find_all('table', {'border': 1})
        for agency_table in agency_tables:
            results = agency_table.select('tr')
            for (index, result) in enumerate(results):
                if (not index):
                    continue
                report = audit_report_from(result, url, year_range)
                if report:
                    if (report_id and (report_id != report['report_id'])):
                        continue
                    inspector.save_report(report)
    doc = beautifulsoup_from_url(SEMIANNUAL_REPORTS_URL)
    table = doc.find('table', {'border': 1})
    for (index, result) in enumerate(table.select('tr')):
        if (index < 2):
            continue
        report = semiannual_report_from(result, SEMIANNUAL_REPORTS_URL, year_range)
        if report:
            if (report_id and (report_id != report['report_id'])):
                continue
            inspector.save_report(report)
    for url in OTHER_REPORTS_URL:
        doc = beautifulsoup_from_url(url)
        results = doc.select('div.contentText ul li')
        for result in results:
            report = report_from(result, url, year_range)
            if report:
                if (report_id and (report_id != report['report_id'])):
                    continue
                inspector.save_report(report)
def run(options):
    year_range = inspector.year_range(options)
    report_id = options.get('report_id')
    for year in year_range:
        url = audit_url_for(year)
        doc = beautifulsoup_from_url(url)
        agency_tables = doc.find_all('table', {'border': 1})
        for agency_table in agency_tables:
            results = agency_table.select('tr')
            for (index, result) in enumerate(results):
                if (not index):
                    continue
                report = audit_report_from(result, url, year_range)
                if report:
                    if (report_id and (report_id != report['report_id'])):
                        continue
                    inspector.save_report(report)
    doc = beautifulsoup_from_url(SEMIANNUAL_REPORTS_URL)
    table = doc.find('table', {'border': 1})
    for (index, result) in enumerate(table.select('tr')):
        if (index < 2):
            continue
        report = semiannual_report_from(result, SEMIANNUAL_REPORTS_URL, year_range)
        if report:
            if (report_id and (report_id != report['report_id'])):
                continue
            inspector.save_report(report)
    for url in OTHER_REPORTS_URL:
        doc = beautifulsoup_from_url(url)
        results = doc.select('div.contentText ul li')
        for result in results:
            report = report_from(result, url, year_range)
            if report:
                if (report_id and (report_id != report['report_id'])):
                    continue
                inspector.save_report(report)