コード例 #1
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')
     r += html_reports.tag('h4', '@href')
     th, data = self.hrefs_sheet_data()
     r += html_reports.sheet(th, data, table_style='validation')
     return r
コード例 #2
0
ファイル: xmlcvrter.py プロジェクト: swarzesherz/PC-Programs
    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.articles_merger.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(pkg_validations.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
コード例 #3
0
 def affiliations(self):
     r = html_reports.tag('p', 'Affiliations:', 'label')
     for item in self.article.affiliations:
         r += html_reports.tag('p', html_reports.format_html_data(item.xml))
     th, w, data = self.affiliations_sheet_data()
     r += html_reports.sheet(th, data)
     return r
コード例 #4
0
ファイル: xmlcvrter.py プロジェクト: swarzesherz/PC-Programs
    def conversion_report(self):
        #resulting_orders
        labels = [_('article'), _('registered') + '/' + _('before conversion'), _('package'), _('executed actions'), _('achieved results')]
        widths = {_('article'): '20', _('registered') + '/' + _('before conversion'): '20', _('package'): '20', _('executed actions'): '20',  _('achieved results'): '20'}

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

        history = sorted([(hist[0][1].order, xml_name) for xml_name, hist in self.articles_merger.history_items.items()])
        history = [(xml_name, self.articles_merger.history_items[xml_name]) for order, xml_name in history]

        items = []
        for xml_name, hist in history:
            values = []
            values.append(article_reports.display_article_data_in_toc(hist[-1][1]))
            values.append(article_reports.article_history([item for item in hist if item[0] == 'registered article']))
            values.append(article_reports.article_history([item for item in hist if item[0] == 'package']))
            values.append(article_reports.article_history([item for item in hist if not item[0] in ['registered article', 'package', 'rejected', 'converted', 'not converted']]))
            values.append(article_reports.article_history([item for item in hist if item[0] in ['rejected', 'converted', 'not converted']]))

            items.append(pkg_validations.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'), _('achieved results')], widths=widths)
コード例 #5
0
ファイル: xmlcvrter.py プロジェクト: leticiaquino/PC-Programs
    def final_status_report(self):
        actions_result_labels = {'delete': 'deleted', 'update': 'updated', 'add': 'added', '-': '-', 'skip-update': 'skipped', 'order changed': 'order changed', 'fail': 'update/add failed', 'block-update': 'update blocked'}
        orders = sorted(list(set([article.order for article in self.previous_registered_articles.values()] + [article.order for article in self.db.registered_articles.values()] + [article.order if article.tree is not None else 'None' for article in self.pkg.articles.values()])))

        sorted_previous_registered = pkg_reports.articles_sorted_by_order(self.previous_registered_articles)
        sorted_registered = pkg_reports.articles_sorted_by_order(self.db.registered_articles)
        sorted_package = pkg_reports.articles_sorted_by_order(self.pkg.articles)

        items = []

        for order in orders:
            if order in sorted_registered.keys():
                # documento na base
                for article in sorted_registered[order]:
                    action = self.actions[article.xml_name]
                    result = actions_result_labels[action]
                    _notes = ''
                    if action == 'update':
                        if article.last_update_display is None:
                            result = 'error'
                        elif self.previous_registered_articles.get(article.xml_name).last_update_display == article.last_update_display:
                            result = 'error'
                        name = article.xml_name
                        if name in self.changed_orders.keys():
                            previous_order, new_order = self.changed_orders[name]
                            _notes = previous_order + '=>' + new_order
                            if result == 'error':
                                _notes = validation_status.STATUS_ERROR + ': ' + _('Unable to replace ') + _notes
                    labels, values = complete_issue_items_row(article, action, result, 'registered', _notes, True)
                    items.append(pkg_reports.label_values(labels, values))
            elif order in sorted_package.keys():
                # documento no pacote mas nao na base
                for article in sorted_package[order]:
                    action = self.actions[article.xml_name]
                    name = article.xml_name
                    _notes = ''
                    if name in self.changed_orders.keys():
                        previous_order, new_order = self.changed_orders[name]
                        _notes = previous_order + '=>' + new_order
                        _notes = validation_status.STATUS_ERROR + ': ' + _('Unable to replace ') + _notes

                    labels, values = complete_issue_items_row(article, action, 'error', 'package', _notes, True)
                    items.append(pkg_reports.label_values(labels, values))
            elif order in sorted_previous_registered.keys():
                # documento anteriormente na base
                for article in sorted_previous_registered[order]:
                    action = 'delete'
                    name = article.xml_name
                    _notes = ''
                    if name in self.changed_orders.keys():
                        previous_order, new_order = self.changed_orders[name]
                        _notes = 'deleted ' + previous_order + '=> new: ' + new_order
                    labels, values = complete_issue_items_row(article, '?', 'deleted', 'excluded', _notes, True)
                    items.append(pkg_reports.label_values(labels, values))
        after_conversion_report = html_reports.tag('h4', _('Documents status in the package/database - after conversion'))
        after_conversion_report += html_reports.sheet(labels, items, 'dbstatus', 'result')
        return after_conversion_report
コード例 #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
コード例 #7
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'])
コード例 #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
コード例 #9
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('')
            label, status, msg, xml = result
            rows.append({'label': sps_help(label), 'status': status, 'message': msg, 'xml': xml, _('why it is not a valid message?'): ' '})
        r = html_reports.tag('div', html_reports.sheet(['label', 'status', 'message', 'xml', _('why it is not a valid message?')], rows, table_style='validation'))
    return r
コード例 #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
コード例 #11
0
ファイル: xmlcvrter.py プロジェクト: leticiaquino/PC-Programs
    def initial_status_report(self):
        report = html_reports.tag('h4', _('Documents status in the package/database - before conversion'))

        orders = [article.order for article in self.previous_registered_articles.values()]
        for article in self.pkg.articles.values():
            if article.tree is None:
                orders.append('None')
            else:
                orders.append(article.order)

        orders = sorted(list(set([order for order in orders if order is not None])))

        sorted_registered = pkg_reports.articles_sorted_by_order(self.previous_registered_articles)
        sorted_package = pkg_reports.articles_sorted_by_order(self.pkg.articles)
        items = []

        for order in orders:
            action = ''
            if order in sorted_registered.keys():
                for article in sorted_registered[order]:
                    action = self.actions[article.xml_name]
                    _notes = ''
                    if action == 'update':
                        if self.previous_registered_articles[article.xml_name].order != self.pkg.articles[article.xml_name].order:
                            action = 'delete'
                            _notes = 'new order=' + self.pkg.articles[article.xml_name].order
                    labels, values = complete_issue_items_row(article, '', '', 'registered', _notes)
                    items.append(pkg_reports.label_values(labels, values))

            if order in sorted_package.keys():
                for article in sorted_package[order]:
                    action = self.actions[article.xml_name]
                    _notes = ''
                    if self.previous_registered_articles.get(article.xml_name) is not None:
                        if self.previous_registered_articles[article.xml_name].order != self.pkg.articles[article.xml_name].order:
                            _notes = _('replacing ') + self.previous_registered_articles[article.xml_name].order
                    labels, values = complete_issue_items_row(article, action, '', 'package', _notes)
                    items.append(pkg_reports.label_values(labels, values))
        return report + html_reports.sheet(labels, items, 'dbstatus', 'action')
コード例 #12
0
 def sources_sheet(self):
     labels, width, data = self.sources_sheet_data()
     return html_reports.tag('h2', _('Sources')) + html_reports.sheet(labels, data)
コード例 #13
0
 def authors_sheet(self):
     labels, width, data = self.authors_sheet_data()
     return html_reports.tag('h2', _('Authors')) + html_reports.sheet(labels, data)
コード例 #14
0
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)