예제 #1
0
 def table_tables(self):
     labels = ['xml', 'data']
     tablewraps_data = []
     for tablewrap in self.article.tables:
         graphics = []
         for g in tablewrap.graphics:
             tag, f = g
             href = os.path.join('{IMG_PATH}', f)
             link = html_reports.link(href, html_reports.thumb_image(href))
             graphics.append('<h4>{}</h4>'.format(tag) + link)
         _codes = [
             u'<h4>{}</h4><div>{}</div>'.format(tag, c)
             for tag, c in tablewrap.codes
         ]
         content = []
         content += ['<b>@id</b>: {}'.format(tablewrap.id)]
         content += [u'<b>label</b>: {}'.format(tablewrap.label)]
         content += graphics
         content += _codes
         content = '<hr/>'.join(content)
         tablewraps_data.append({
             'xml': tablewrap.xml,
             'data': ' ' + content + ' '
         })
     return html_reports.tag('h1', 'table-wrap') + html_reports.sheet(
         labels,
         tablewraps_data,
         table_style='none',
         html_cell_content=['data'])
예제 #2
0
 def link_to_pdf_and_xml_files(self):
     items = []
     for item in list(self.article.expected_pdf_files.values()) + [
             self.article.filename
     ]:
         location = '{PDF_PATH}' if item.endswith('.pdf') else '{XML_PATH}'
         items.append(
             html_reports.tag(
                 'p', html_reports.link(os.path.join(location, item),
                                        item)))
     return ''.join(items)
예제 #3
0
 def _is_valid_orcid(self, orcid, contrib_name):
     contrib_orcid_url = '{}{}'.format(self.ORCID_MAIN_URL, orcid)
     if self.is_available_orcid_website:
         if not self.ws_requester.is_valid_url(contrib_orcid_url):
             return (
                 'contrib-id',
                 validation_status.STATUS_FATAL_ERROR,
                 _('{value} is an invalid value for {label}. ').format(
                     value=orcid, label='ORCID'))
     return ('contrib-id',
             validation_status.STATUS_WARNING,
             _('Unable to check if {} belongs to {}. ').format(
                 html_reports.link(contrib_orcid_url, orcid),
                 contrib_name.fullname))
예제 #4
0
 def pkg_journal_validations(self):
     items = validations_module.ValidationsResultItems()
     for name, validation in self.pkg_articles_validations.items():
         items[name] = validation.journal_validations
     signal = ''
     msg = ''
     if not self.is_db_generation:
         signal = '<sup>*</sup>'
         msg = html_reports.tag(
             'h5', '<a name="note"><sup>*</sup></a>' +
             _('Journal data in the XML files must be consistent with {link}'
               ).format(link=html_reports.link(
                   'http://static.scielo.org/sps/titles-tab-v2-utf-8.csv',
                   'http://static.scielo.org/sps/titles-tab-v2-utf-8.csv')),
             'note')
     items.title = html_reports.tag(
         'h2',
         _('Journal data: XML files and registered data') + signal) + msg
     return items
예제 #5
0
    def convert_package(self, pkg):
        if len(pkg.package_folder.xml_list) == 0:
            raise PackageHasNoXMLFilesError(
                _("Unable to convert package {}, "
                  "because it has no XML files").format(
                      pkg.package_folder.path))

        registered_issue_data, pkg_eval_result = self.evaluate_package(pkg)

        conversion = ArticlesConversion(registered_issue_data, pkg,
                                        pkg_eval_result,
                                        not self.config.interative_mode,
                                        self.config.local_web_app_path,
                                        self.config.web_app_site)

        if self.config.pid_manager_info:
            with PIDVersionsDB(self.config.pid_manager_info) as db:
                conversion.register_pids_and_update_xmls(
                    PIDVersionsManager(db))

        scilista_items = conversion.convert()

        # A scilista sempre terá um item mas o pacote só será
        # exportado se a scilista tiver mais de um item, isso
        # indica que o pacote está válido
        if scilista_items is not None and len(scilista_items) > 1:
            conversion.export_package_to_spf_directory(
                self.export_documents_package, package_name=scilista_items[0])
            conversion.update_local_website_with_asset_files()

        reports = self.report_result(pkg, pkg_eval_result, conversion)
        statistics_display = reports.validations.statistics_display(
            html_format=False)

        subject = ' '.join(
            EMAIL_SUBJECT_STATUS_ICON.get(conversion.xc_status,
                                          [])) + ' ' + statistics_display
        mail_content = '<html><body>' + html_reports.link(
            reports.report_link, reports.report_link) + '</body></html>'
        mail_info = subject, mail_content
        return (scilista_items, conversion.xc_status, mail_info)
예제 #6
0
    def _table_tables(self):
        r = '<!-- no tables -->'
        if self.article.tables:
            r += '<h1>Tables</h1>'

            for table in self.article.tables:
                rows = ['<h2>{}</h2>'.format(table.id)]
                rows += [
                    html_reports.tag('div',
                                     html_reports.format_html_data(table.xml),
                                     'xml')
                ]
                rows += [u'<h4>label</h4>{}'.format(table.label)]
                for tag, item in table.codes:
                    rows += [u'<h4>{}</h4><div>{}</div>'.format(tag, item)]
                for tag, item in table.graphics:
                    href = os.path.join('{IMG_PATH}', item)
                    link = html_reports.link(href,
                                             html_reports.thumb_image(href))
                    rows += [u'<h4>{}</h4><{}'.format(tag, link)]
                r += html_reports.tag('div', '<hr/>'.join(rows))
        return r
예제 #7
0
 def display_formulas(self):
     labels = ['xml', 'data']
     formulas_data = []
     for formula in self.article.formulas:
         graphics = []
         for g in formula.graphics:
             tag, f = g
             href = os.path.join('{IMG_PATH}', f)
             link = html_reports.link(href, html_reports.thumb_image(href))
             graphics.append('<h4>{}</h4>'.format(tag) + link)
         _graphics = '<hr/>'.join(graphics)
         _codes = [
             u'<h4>{}</h4><div>{}</div>'.format(tag, c)
             for tag, c in formula.codes
         ]
         content = []
         content += ['<b>@id</b>: {}'.format(formula.id)]
         content += [_graphics]
         content += _codes
         content = '<hr/>'.join(content)
         formulas_data.append({'xml': formula.xml, 'data': content})
     return html_reports.tag('h1', '*-formula') + html_reports.sheet(
         labels, formulas_data, table_style='none')
예제 #8
0
 def display_image(self, img_filename, style, origin, selected):
     rows = []
     if origin == selected:
         icon = "&#x2713;"
         text = _('[selected]')
     else:
         icon = "&#x2717;"
         text = _("[not selected]")
     rows.append(
         html_reports.tag(
             'h4', _('Image from {} {} {}').format(origin, icon, text)))
     rows.append(
         html_reports.tag('p', img_filename))
     basename = os.path.basename(img_filename)
     name, ext = os.path.splitext(img_filename)
     if ext.startswith(".tif"):
         link = basename
     else:
         link = html_reports.image(img_filename)
     rows.append(
             '<div class="{}">'.format(style) +
             html_reports.link(img_filename, link) + '</div>')
     return ''.join(rows)