def audit_report_from(result, page_url, year_range):
    if (not result.text.strip()):
        return
    title = result.select('td')[0].text.strip()
    report_url = urljoin(page_url, result.select('td a')[0].get('href'))
    report_id = None
    if (len(result.select('td')) != 3):
        report_id = result.select('td')[1].text.strip()
    if (not report_id):
        report_filename = report_url.split('/')[(- 1)]
        (report_id, extension) = os.path.splitext(report_filename)
    if (report_id in REPORT_PUBLISHED_MAP):
        published_on = REPORT_PUBLISHED_MAP[report_id]
    else:
        published_on_text = result.select('td')[2].text.strip().replace(')', '').replace('//', '/')
        date_formats = ['%m/%d/%Y', '%m/%d/%y', '%m/%Y']
        published_on = None
        for date_format in date_formats:
            try:
                published_on = datetime.datetime.strptime(published_on_text, date_format)
            except ValueError:
                pass
    if (published_on.year not in year_range):
        logging.debug(('[%s] Skipping, not in requested range.' % report_url))
        return
    report = {'inspector': 'education', 'inspector_url': 'https://www2.ed.gov/about/offices/list/oig/', 'agency': 'education', 'agency_name': 'Department of Education', 'report_id': report_id, 'url': report_url, 'title': title, 'published_on': datetime.datetime.strftime(published_on, '%Y-%m-%d')}
    return report
def audit_report_from(result, page_url, year_range):
    if (not result.text.strip()):
        return
    title = result.select('td')[0].text.strip()
    report_url = urljoin(page_url, result.select('td a')[0].get('href'))
    report_id = None
    if (len(result.select('td')) != 3):
        report_id = result.select('td')[1].text.strip()
    if (not report_id):
        report_filename = report_url.split('/')[(- 1)]
        (report_id, extension) = os.path.splitext(report_filename)
    if (report_id in REPORT_PUBLISHED_MAP):
        published_on = REPORT_PUBLISHED_MAP[report_id]
    else:
        published_on_text = result.select('td')[2].text.strip().replace(')', ).replace('//', '/')
        date_formats = ['%m/%d/%Y', '%m/%d/%y', '%m/%Y']
        published_on = None
        for date_format in date_formats:
            try:
                published_on = datetime.datetime.strptime(published_on_text, date_format)
            except ValueError:
                pass
    if (published_on.year not in year_range):
        logging.debug(('[%s] Skipping, not in requested range.' % report_url))
        return
    report = {'inspector': 'education', 'inspector_url': 'https://www2.ed.gov/about/offices/list/oig/', 'agency': 'education', 'agency_name': 'Department of Education', 'report_id': report_id, 'url': report_url, 'title': title, 'published_on': datetime.datetime.strftime(published_on, '%Y-%m-%d')}
    return report