Exemplo n.º 1
0
    def articles_dates_report(self):
        labels = [
            'name', '@article-type', 'received', 'accepted',
            'receive to accepted (days)', 'SciELO date', 'editorial date',
            'accepted to SciELO (days)', 'accepted to nowadays (days)'
        ]
        items = []
        for xml_name, doc in self.articles:
            values = []
            values.append(xml_name)
            values.append(doc.article_type)
            values.append(utils.display_datetime(doc.received_dateiso))
            values.append(utils.display_datetime(doc.accepted_dateiso))
            values.append(str(doc.history_days))
            values.append(
                utils.display_datetime(doc.isoformat(doc.real_pubdate)))
            values.append(
                utils.display_datetime(doc.isoformat(doc.expected_pubdate)))
            values.append(str(doc.accepted_to_real_in_days))
            values.append(str(doc.accepted_to_nowadays_in_days))
            items.append(html_reports.label_values(labels, values))
        article_dates = html_reports.sheet(labels, items, 'dbstatus')

        labels = [_('year'), _('location')]
        items = []
        for year in sorted(self.years.keys()):
            values = []
            values.append(year)
            values.append(self.years[year])
            items.append(html_reports.label_values(labels, values))
        reference_dates = html_reports.sheet(labels, items, 'dbstatus')

        return html_reports.tag(
            'h4', _('Articles Dates Report')) + article_dates + reference_dates
Exemplo n.º 2
0
 def files_and_href(self):
     r = ''
     r += html_reports.tag('h4', _('Files in the package'))
     th, data = self.package_files()
     r += html_reports.sheet(th, data, table_style='validation_sheet')
     r += html_reports.tag('h4', '@href')
     th, data = self.hrefs_sheet_data()
     r += html_reports.sheet(th, data, table_style='validation_sheet')
     return r
Exemplo n.º 3
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'])
Exemplo n.º 4
0
def validations_table(results):
    r = ''
    if results is not None:
        rows = []
        for result in results:
            result = list(result)
            if len(result) == 3:
                result.append('')
            if len(result) == 4:
                label, status, msg, xml = result
                rows.append({
                    'label': attributes.sps_help(label),
                    'status': status,
                    'message': msg,
                    'xml': xml,
                    _('why it is not a valid message?'): ' '
                })
            else:
                logger.debug('validations_table: ', result)
        r = html_reports.tag(
            'div',
            html_reports.sheet([
                'label', 'status', 'message', 'xml',
                _('why it is not a valid message?')
            ],
                               rows,
                               table_style='validation_sheet'))
    return r
Exemplo n.º 5
0
 def affiliations(self):
     r = html_reports.tag('p', 'Affiliations:', 'label')
     for aff_xml in self.article.affiliations:
         r += html_reports.tag(
             'p', html_reports.format_html_data(aff_xml.aff.xml))
     th, w, data = self.affiliations_sheet_data()
     r += html_reports.sheet(th, data)
     return r
Exemplo n.º 6
0
 def references_stats(self):
     r = html_reports.tag('h2', 'references')
     sheet_data = []
     for ref_type, q in self.article.refstats.items():
         row = {}
         row['element-citation/@publication-type'] = ref_type
         row['quantity'] = q
         sheet_data.append(row)
     r += html_reports.sheet(
         ['element-citation/@publication-type', 'quantity'], sheet_data)
     return r
Exemplo n.º 7
0
    def report_articles_merging_conflicts(self):
        if not hasattr(self, '_report_articles_merging_conflicts'):
            merging_errors = []
            if len(self.docs_merger.titaut_conflicts) + len(
                    self.docs_merger.name_order_conflicts) > 0:

                keys = list(self.docs_merger.titaut_conflicts.keys()) + list(
                    self.docs_merger.name_order_conflicts.keys())
                keys = sorted(list(set(keys)))

                merging_errors = [
                    html_reports.p_message(
                        validation_status.STATUS_BLOCKING_ERROR + ': ' +
                        _('Unable to update because the registered article data and the package article data do not match. '
                          ))
                ]

                articles = self.docs_merger.articles
                registered_articles = self.docs_merger.registered_articles
                for name in keys:
                    labels = [
                        name,
                        _('title/author conflicts'),
                        _('name/order conflicts')
                    ]
                    values = [
                        article_data_reports.display_article_data_to_compare(
                            articles.get(name))
                    ]

                    articles_in_conflict = []
                    for reg_name, art in self.docs_merger.titaut_conflicts.get(
                            name, {}).items():
                        articles_in_conflict.append(
                            article_data_reports.
                            display_article_data_to_compare(art))
                    values.append(''.join(articles_in_conflict))

                    articles_in_conflict = []
                    for pkg_name, art in self.docs_merger.name_order_conflicts.get(
                            name, {}).items():
                        articles_in_conflict.append(
                            article_data_reports.
                            display_article_data_to_compare(art))
                    values.append(''.join(articles_in_conflict))

                    merging_errors.append(
                        html_reports.sheet(
                            labels,
                            [html_reports.label_values(labels, values)],
                            table_style='dbstatus',
                            html_cell_content=labels))
            self._report_articles_merging_conflicts = ''.join(merging_errors)
        return self._report_articles_merging_conflicts
Exemplo n.º 8
0
 def id_and_tag_list(self):
     sheet_data = []
     t_header = ['@id', 'tag']
     for item in self.article.elements_which_has_id_attribute:
         row = {}
         row['@id'] = item.attrib.get('id')
         row['tag'] = item.tag
         sheet_data.append(row)
     r = html_reports.tag('h2', 'elements and @id:')
     r += html_reports.sheet(t_header, sheet_data)
     return r
Exemplo n.º 9
0
 def articles_affiliations_report(self):
     r = html_reports.tag('h4', _('Affiliations Report'))
     items = []
     for label, occs in self.compiled_affiliations.items():
         items.append({
             'label': label,
             'quantity': str(len(occs)),
             _('files'): sorted(list(set(occs)))
         })
     r += html_reports.sheet(
         ['label', 'quantity', _('files')], items, 'dbstatus')
     return r
Exemplo n.º 10
0
 def id_and_xml_list(self):
     sheet_data = []
     t_header = ['@id', 'xml']
     for item in self.article.elements_which_has_id_attribute:
         row = {}
         row['@id'] = item.attrib.get('id')
         row['xml'] = xml_utils.node_xml(item)
         if '>' in row['xml']:
             row['xml'] = row['xml'][0:row['xml'].find('>') + 1]
         sheet_data.append(row)
     r = html_reports.tag('h2', 'elements and @id:')
     r += html_reports.sheet(t_header, sheet_data)
     return r
Exemplo n.º 11
0
 def sources_overview_report(self):
     labels = ['source', _('location')]
     h = ''
     if len(self.reftype_and_sources) > 0:
         for reftype, sources in self.reftype_and_sources.items():
             items = []
             h += html_reports.tag('h4', reftype)
             for source in sorted(sources.keys()):
                 items.append({
                     'source': source,
                     _('location'): sources[source]
                 })
             h += html_reports.sheet(labels, items, 'dbstatus')
     return h
Exemplo n.º 12
0
def evaluate_journal_data(items):
    unmatched = []
    for label, value, expected_values, default_status in items:
        if expected_values is None:
            expected_values = [None]
        if len(expected_values) == 0:
            expected_values.extend([None, ''])
        status = validation_status.STATUS_OK
        if value not in expected_values:
            status = default_status
            for expected_value in expected_values:
                if expected_value is not None and value is not None:
                    if '/' + expected_value.lower() + '/' in value.lower(
                    ) + '/':
                        status = validation_status.STATUS_OK
                        break

        if status != validation_status.STATUS_OK:
            if None in expected_values:
                expected_values = [
                    item for item in expected_values if item is not None
                ]
                expected_values.append(_('none'))
            unmatched.append({
                _('data'):
                label,
                'status':
                status,
                'XML':
                value,
                _('registered journal data') + '*':
                _(' or ').join(expected_values),
                _('why it is not a valid message?'):
                ''
            })

    validations_result = ''
    if len(unmatched) > 0:
        validations_result = html_reports.sheet([
            _('data'), 'status', 'XML',
            _('registered journal data') + '*',
            _('why it is not a valid message?')
        ],
                                                unmatched,
                                                table_style='dbstatus')
    return validations_result
Exemplo n.º 13
0
    def aop_report(self, status, status_items):
        if status_items is None:
            return ''
        r = ''
        if len(status_items) > 0:
            labels = []
            widths = {}
            if status == 'aop':
                labels = [_('issue')]
                widths = {_('issue'): '5'}
            labels.extend([_('filename'), 'order', _('article')])
            widths.update({
                _('filename'): '5',
                'order': '2',
                _('article'): '88'
            })

            report_items = []
            for item in status_items:
                issueid = None
                article = None
                if status == 'aop':
                    issueid, name, article = item
                else:
                    name = item
                    article = self.pkg_eval_result.merged_articles.get(name)
                if article is not None:
                    if not article.is_ex_aop:
                        values = []
                        if issueid is not None:
                            values.append(issueid)
                        values.append(name)
                        values.append(article.order)
                        values.append(article.title)
                        report_items.append(
                            html_reports.label_values(labels, values))
            r = html_reports.tag('h3', _(status)) + html_reports.sheet(
                labels,
                report_items,
                table_style='reports-sheet',
                html_cell_content=[_('article')],
                widths=widths)
        return r
Exemplo n.º 14
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')
Exemplo n.º 15
0
    def conversion_report(self):
        #resulting_orders
        labels = [
            _('registered') + '/' + _('before conversion'),
            _('package'),
            _('executed actions'),
            _('article')
        ]
        widths = {
            _('article'): '20',
            _('registered') + '/' + _('before conversion'): '20',
            _('package'): '20',
            _('executed actions'): '20'
        }

        for status, status_items in self.aop_status.items():
            for status_data in status_items:
                if status != 'aop':
                    name = status_data
                    self.pkg_eval_result.history_items[name].append(status)
        for status, names in self.conversion_status.items():
            for name in names:
                self.pkg_eval_result.history_items[name].append(status)

        items = []
        db_articles = self.registered_articles or {}
        for xml_name in sorted(self.pkg_eval_result.history_items.keys()):
            pkg = self.pkg.articles.get(xml_name)
            registered = self.pkg_eval_result.registered_articles.get(xml_name)
            merged = db_articles.get(xml_name)

            diff = ''
            if registered is not None and pkg is not None:
                comparison = article_data_reports.ArticlesComparison(
                    registered, pkg)
                diff = comparison.display_articles_differences()
                if diff != '':
                    diff += '<hr/>'

            values = []
            values.append(
                article_data_reports.display_article_data_to_compare(
                    registered) if registered is not None else '')
            values.append(
                article_data_reports.display_article_data_to_compare(pkg)
                if pkg is not None else '')
            values.append(
                article_data_reports.article_history(
                    self.pkg_eval_result.history_items[xml_name]))
            values.append(diff +
                          article_data_reports.display_article_data_to_compare(
                              merged) if merged is not None else '')

            items.append(html_reports.label_values(labels, values))
        return html_reports.tag(
            'h3', _('Conversion steps')) + html_reports.sheet(
                labels,
                items,
                html_cell_content=[
                    _('article'),
                    _('registered') + '/' + _('before conversion'),
                    _('package'),
                    _('executed actions')
                ],
                widths=widths)
Exemplo n.º 16
0
    def report_issue_page_values(self):
        # FIXME separar validacao e relatório
        if not hasattr(self, '_report_issue_page_values'):
            results = []
            previous = None

            error_level = validation_status.STATUS_BLOCKING_ERROR
            fpage_and_article_id_other_status = [
                all([a.fpage, a.lpage, a.article_id_other])
                for xml_name, a in self.group.articles
            ]
            if all(fpage_and_article_id_other_status):
                error_level = validation_status.STATUS_ERROR

            for xml_name, article in self.group.articles:
                msg = []
                status = ''
                if article.pages == '':
                    msg.append(_('no pagination was found. '))
                    if not article.is_ahead:
                        status = validation_status.STATUS_ERROR
                if all([article.fpage_number, article.lpage_number]):
                    if previous is not None:
                        if previous.lpage_number > article.fpage_number:
                            status = error_level if not article.is_rolling_pass else validation_status.STATUS_WARNING
                            msg.append(
                                _('Invalid value for fpage and lpage. Check lpage={lpage} ({previous_article}) and fpage={fpage} ({xml_name}). '
                                  ).format(previous_article=previous.prefix,
                                           xml_name=xml_name,
                                           lpage=previous.lpage,
                                           fpage=article.fpage))
                        elif previous.lpage_number + 1 < article.fpage_number:
                            status = validation_status.STATUS_WARNING
                            msg.append(
                                _('There is a gap between lpage={lpage} ({previous_article}) and fpage={fpage} ({xml_name}). '
                                  ).format(previous_article=previous.prefix,
                                           xml_name=xml_name,
                                           lpage=previous.lpage,
                                           fpage=article.fpage))
                        if previous.fpage_number == article.fpage_number:
                            if all([previous.fpage_seq, article.fpage_seq
                                    ]) is False:
                                msg.append(
                                    _('Same value for fpage={fpage} ({previous_article} and {xml_name}) requires @seq for both fpage. '
                                      ).format(
                                          previous_article=previous.prefix,
                                          xml_name=xml_name,
                                          lpage=previous.fpage,
                                          fpage=article.fpage))
                            elif previous.fpage_seq > article.fpage_seq:
                                msg.append(
                                    _('fpage/@seq must be a and b: {a} ({previous_article}) and {b} ({xml_name}). '
                                      ).format(
                                          previous_article=previous.prefix,
                                          xml_name=xml_name,
                                          a=previous.fpage_seq,
                                          b=article.fpage_seq))
                    if article.fpage_number > article.lpage_number:
                        status = error_level
                        msg.append(
                            _('Invalid page range: {fpage} (fpage) > {lpage} (lpage). '
                              .format(fpage=article.fpage_number,
                                      lpage=article.lpage_number)))
                    previous = article

                msg = '\n'.join(msg)
                results.append({
                    'label': xml_name,
                    'status': status,
                    'pages': article.pages,
                    'message': msg,
                    _('why it is not a valid message?'): ''
                })
            self._report_issue_page_values = html_reports.tag(
                'h2', _('Pages Report')) + html_reports.tag(
                    'div',
                    html_reports.sheet(
                        [
                            'label', 'status', 'pages', 'message',
                            _('why it is not a valid message?')
                        ],
                        results,
                        table_style='validation_sheet',
                        widths={
                            'label': '10',
                            'status': '10',
                            'pages': '5',
                            'message': '75'
                        }))
        return self._report_issue_page_values
Exemplo n.º 17
0
    def references_overview_report(self):
        labels = [
            'label', 'status', 'message',
            _('why it is not a valid message?')
        ]
        items = []
        values = []
        values.append(_('references by type'))
        values.append(validation_status.STATUS_INFO)
        values.append({
            reftype: str(sum([len(occ) for occ in sources.values()]))
            for reftype, sources in self.reftype_and_sources.items()
        })
        values.append('')
        items.append(html_reports.label_values(labels, values))

        if len(self.bad_sources_and_reftypes) > 0:
            values = []
            values.append(_('same sources as different types references'))
            values.append(validation_status.STATUS_ERROR)
            values.append(self.bad_sources_and_reftypes)
            values.append('')
            items.append(html_reports.label_values(labels, values))

        if len(self.missing_source) > 0:
            items.append({
                'label':
                _('references missing source'),
                'status':
                validation_status.STATUS_ERROR,
                'message': [' - '.join(item) for item in self.missing_source],
                _('why it is not a valid message?'):
                ''
            })
        if len(self.missing_year) > 0:
            items.append({
                'label':
                _('references missing year'),
                'status':
                validation_status.STATUS_ERROR,
                'message': [' - '.join(item) for item in self.missing_year],
                _('why it is not a valid message?'):
                ''
            })
        if len(self.unusual_sources) > 0:
            items.append({
                'label':
                _('references with unusual value for source'),
                'status':
                validation_status.STATUS_ERROR,
                'message': [' - '.join(item) for item in self.unusual_sources],
                _('why it is not a valid message?'):
                ''
            })
        if len(self.unusual_years) > 0:
            items.append({
                'label':
                _('references with unusual value for year'),
                'status':
                validation_status.STATUS_ERROR,
                'message': [' - '.join(item) for item in self.unusual_years],
                _('why it is not a valid message?'):
                ''
            })

        return html_reports.tag(
            'h4', _('Package references overview')) + html_reports.sheet(
                labels, items, table_style='dbstatus')
Exemplo n.º 18
0
 def authors_sheet(self):
     labels, width, data = self.authors_sheet_data()
     return html_reports.tag('h2', _('Authors')) + html_reports.sheet(
         labels, data)
Exemplo n.º 19
0
 def sources_sheet(self):
     labels, width, data = self.sources_sheet_data()
     return html_reports.tag('h2', _('Sources')) + html_reports.sheet(
         labels, data)