Beispiel #1
0
def save_packtools_style_report(content, report_filename):
    version = ''
    try:
        import pkg_resources
        version = pkg_resources.get_distribution('packtools').version
    except:
        pass

    q = len(content.split('SPS-ERROR')) - 1
    msg = ''
    title = 'Style Checker (packtools' + version + ')'
    if q > 0:
        msg = html_reports.tag('div', 'Total of errors = ' + str(q), 'error')

    body = msg + ''.join([html_reports.display_xml(item) for item in content.split('\n')])
    html_reports.save(report_filename, title, body)
path = curr_path + '/../../aff'

print(path)
if not os.path.isdir(path):
    os.makedirs(path)

if os.path.isdir(path):
    links = []
    labels = ['name', 'city', 'state']
    for country in sorted(countries.keys()):
        name, code = country.split(' - ')
        print(country)
        links.append(html_reports.link('./' + code + '.html', country))

        rows = []
        for items in countries[country]:
            print(items)
            org, city, state = items.split('\t')
            tr = {}
            tr['name'] = org
            tr['city'] = city
            tr['state'] = state
            rows.append(tr)
        content = html_reports.sheet(labels, rows)
        print(path + '/' + code + '.html')
        html_reports.save(path + '/' + code + '.html', country, content)

    content = html_reports.format_list('', 'ol', links)
    print(path + '/aff.html')
    html_reports.save(path + '/aff.html', 'Affiliations', content)