def old_link_to_pdf_items(self, page_id=''):
     items = []
     pdf = self.xml_path + '/' + self.xml_name + '.pdf'
     if os.path.isfile(pdf):
         #items.append('<object id="' + pdf_id + '" data="file://' + pdf + '" width="100%" height="100%"><param name="view" value="Fit" /></object>')
         items.append(html_reports.link(pdf, os.path.basename(pdf)))
     for lang in self.article.trans_languages:
         pdf = self.xml_path + '/' + self.xml_name + '-' + lang + '.pdf'
         if os.path.isfile(pdf):
             items.append(html_reports.link(pdf, os.path.basename(pdf)))
     return ''.join(items)
 def link_to_pdf_items(self):
     items = []
     for item in self.article.related_files:
         items.append(html_reports.tag('p', html_reports.link(
             item,
             os.path.basename(item), window=('800', '400'))))
     return ''.join(items)
Пример #3
0
 def link_to_pdf_and_xml_files(self):
     items = []
     for item in self.article.related_files:
         location = '{PDF_PATH}' if item.endswith('.pdf') else '{XML_PATH}'
         items.append(html_reports.tag('p', html_reports.link(
             location + item,
             item, window=('1000', '400'))))
     return ''.join(items)
Пример #4
0
 def display_formulas(self):
     labels = ['id', 'code', 'graphic', 'xml']
     formulas_data = []
     for formula_data in self.article.formulas_data:
         if formula_data['graphic'] is not None:
             formula_data['graphic'] = html_reports.link('{IMG_PATH}/' + formula_data['graphic'], html_reports.image('{IMG_PATH}/' + formula_data['graphic']))
         if formula_data['code'] is not None:
             formula_data['code'] = formula_data['code'].replace('mml:', '')
         formulas_data.append(formula_data)
     return html_reports.tag('h1', _('Equations')) + html_reports.sheet(labels, formulas_data, html_cell_content=['code'])
Пример #5
0
def sps_help(label):
    r = label
    if label in attributes.SPS_HELP_ELEMENTS:
        href = 'http://docs.scielo.org/projects/scielo-publishing-schema/pt_BR/latest/tagset/elemento-{label}.html'.format(label=label)
        r += ' ' + html_reports.link(href, '[?]')
    return r
print(__file__)
print(curr_path)
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)
Пример #7
0
def execute_converter(package_paths, collection_name=None):
    collection_names = {}
    collection_acron = collection_names.get(collection_name)
    if collection_acron is None:
        collection_acron = collection_name

    config = xc.get_configuration(collection_acron)
    if config is not None:
        prepare_env(config)
        invalid_pkg_files = []

        mailer = xc.get_mailer(config)

        if package_paths is None:
            package_paths, invalid_pkg_files = queue_packages(config.download_path, config.temp_path, config.queue_path, config.archive_path)
        if package_paths is None:
            package_paths = []
        if not isinstance(package_paths, list):
            package_paths = [package_paths]

        for package_path in package_paths:
            package_folder = os.path.basename(package_path)
            utils.display_message(package_path)
            scilista_items = []
            xc_status = 'interrupted'
            stats_msg = ''
            report_location = None

            try:
                scilista_items, xc_status, stats_msg, report_location = convert_package(package_path)
            except Exception as e:
                if config.queue_path is not None:
                    fs_utils.delete_file_or_folder(package_path)
                if config.email_subject_invalid_packages is not None:
                    send_message(mailer, config.email_to_adm, '[Step 1]' + config.email_subject_invalid_packages, config.email_text_invalid_packages + '\n' + package_folder + '\n' + str(e))
                if len(package_paths) == 1:
                    raise
            print(scilista_items)
            try:
                acron, issue_id = scilista_items[0].split(' ')

                if xc_status in ['accepted', 'approved']:
                    if config.collection_scilista is not None:
                        open(config.collection_scilista, 'a+').write('\n'.join(scilista_items) + '\n')

                    if config.is_enabled_transference:
                        transfer_website_files(acron, issue_id, config.local_web_app_path, config.transference_user, config.transference_servers, config.remote_web_app_path)

                if report_location is not None:
                    if config.email_subject_package_evaluation is not None:
                        results = ' '.join(EMAIL_SUBJECT_STATUS_ICON.get(xc_status, [])) + ' ' + stats_msg
                        link = config.web_app_site + '/reports/' + acron + '/' + issue_id + '/' + os.path.basename(report_location)
                        report_location = '<html><body>' + html_reports.link(link, link) + '</body></html>'

                        transfer_report_files(acron, issue_id, config.local_web_app_path, config.transference_user, config.transference_servers, config.remote_web_app_path)
                        send_message(mailer, config.email_to, config.email_subject_package_evaluation + u' ' + package_folder + u': ' + results, report_location)

            except Exception as e:
                if config.email_subject_invalid_packages is not None:
                    send_message(mailer, config.email_to_adm, '[Step 2]' + config.email_subject_invalid_packages, config.email_text_invalid_packages + '\n' + package_folder + '\n' + str(e))

                if len(package_paths) == 1:
                    print('exception as finishing')
                    raise

        if len(invalid_pkg_files) > 0:
            if config.email_subject_invalid_packages is not None:
                send_message(mailer, config.email_to, config.email_subject_invalid_packages, config.email_text_invalid_packages + '\n'.join(invalid_pkg_files))

    utils.display_message(_('finished'))