def report_from(result, url, year_range):
    report_url = urljoin(url, result.select('a')[0].get('href'))
    report_filename = report_url.split('/')[(- 1)]
    (report_id, extension) = os.path.splitext(report_filename)
    title = result.text.split(' ACN:')[0]
    if (report_id in REPORT_PUBLISHED_MAP):
        published_on = REPORT_PUBLISHED_MAP[report_id]
    else:
        result_text = result.text.replace(',', '').replace('\n', ' ')
        result_text = ' '.join(result_text.split())
        result_text = result_text.replace('Decemver', 'December').replace('Deccember', 'December')
        try:
            published_on_text = '/'.join(re.search('(\\d+)/(\\d+)/(\\d+)', result_text).groups())
            published_on = datetime.datetime.strptime(published_on_text, '%m/%d/%Y')
        except AttributeError:
            try:
                published_on_text = '/'.join(re.search('(\\d+)/(\\d+)', result_text).groups())
                published_on = datetime.datetime.strptime(published_on_text, '%m/%Y')
            except AttributeError:
                try:
                    published_on_text = '/'.join(re.search('(\\w+) (\\d+) (\\d+)', result_text).groups())
                    published_on = datetime.datetime.strptime(published_on_text, '%B/%d/%Y')
                except AttributeError:
                    published_on_text = '/'.join(re.search('(\\w+) (\\d+)', result_text).groups())
                    published_on = datetime.datetime.strptime(published_on_text, '%B/%Y')
    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 report_from(result, url, year_range):
    report_url = urljoin(url, result.select('a')[0].get('href'))
    report_filename = report_url.split('/')[(- 1)]
    (report_id, extension) = os.path.splitext(report_filename)
    title = result.text.split(' ACN:')[0]
    if (report_id in REPORT_PUBLISHED_MAP):
        published_on = REPORT_PUBLISHED_MAP[report_id]
    else:
        result_text = result.text.replace(',', ).replace('\n', ' ')
        result_text = ' '.join(result_text.split())
        result_text = result_text.replace('Decemver', 'December').replace('Deccember', 'December')
        try:
            published_on_text = '/'.join(re.search('(\\d+)/(\\d+)/(\\d+)', result_text).groups())
            published_on = datetime.datetime.strptime(published_on_text, '%m/%d/%Y')
        except AttributeError:
            try:
                published_on_text = '/'.join(re.search('(\\d+)/(\\d+)', result_text).groups())
                published_on = datetime.datetime.strptime(published_on_text, '%m/%Y')
            except AttributeError:
                try:
                    published_on_text = '/'.join(re.search('(\\w+) (\\d+) (\\d+)', result_text).groups())
                    published_on = datetime.datetime.strptime(published_on_text, '%B/%d/%Y')
                except AttributeError:
                    published_on_text = '/'.join(re.search('(\\w+) (\\d+)', result_text).groups())
                    published_on = datetime.datetime.strptime(published_on_text, '%B/%Y')
    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