Пример #1
0
    def dump_rst(self, lines):
        lines.append('Installed packages')
        lines.append('-----------------------------')
        for list in self._cpv_flag_list:
            package_name, version_revision, SLOT, keyword_status, \
                masked, unmasked, is_in_world, repo, sorted_flags_list = \
                list

            lines.append('- %s-%s' % (package_name, version_revision))

            if SLOT != '0':  # Hide default slot
                lines.append('  - Slot: %s' % (SLOT))
            if keyword_status:
                lines.append('  - Keyword status: %s' % keyword_status)

            tag_names = ('masked', 'unmasked', 'world')
            values = (masked, unmasked, is_in_world)
            tags = []
            for i, v in enumerate(values):
                if v:
                    tags.append(tag_names[i])
            if tags:
                lines.append('  - Tags: %s' % ', '.join(tags))

            if repo:
                lines.append('  - Repository: %s' % (repo))
            if sorted_flags_list:
                final_flag_list = [x.startswith('-') and x or ('+' + x) for x in \
                        compress_use_flags(sorted_flags_list)]
                lines.append('  - Use flags: %s' % ', '.join(final_flag_list))
Пример #2
0
    def dump_html(self, lines):
        def fix_empty(text):
            if text == '':
                return ' '
            else:
                return text

        lines.append('<h2>Installed packages</h2>')
        lines.append('<table border="1" cellspacing="1" cellpadding="4">')
        lines.append('<tr>')
        for i in ('Package', 'Version', 'Slot', 'Keyword', 'Masked', 'Unmasked', 'World', 'Tree', 'Use flags'):
            lines.append('<th>%s</th>' % i)
        lines.append('</tr>')
        for list in self._cpv_flag_list:
            package_name, version_revision, SLOT, keyword_status, \
                masked, unmasked, is_in_world, repo, sorted_flags_list = \
                list

            lines.append('<tr>')
            for i in (package_name, version_revision):
                lines.append('<td>%s</td>' % html.escape(i))
            for i in (SLOT, ):
                if i == '0':  # Hide default slot
                    v = '&nbsp;'
                else:
                    v = html.escape(i)
                lines.append('<td>%s</td>' % v)
            for i in (keyword_status, ):
                lines.append('<td>%s</td>' % fix_empty(html.escape(i)))
            for i in (masked, unmasked, is_in_world):
                v = i and 'X' or '&nbsp;'  # Hide False
                lines.append('<td>%s</td>' % v)
            for i in (repo, ):
                lines.append('<td>%s</td>' % fix_empty(html.escape(i)))
            final_flag_list = [x.startswith('-') and \
                    '<s>%s</s>' % html.escape(x.lstrip('-')) or \
                    html.escape(x) for x in \
                    compress_use_flags(sorted_flags_list)]
            lines.append('<td>%s</td>' % fix_empty(', '.join(final_flag_list)))
            lines.append('</tr>')
        lines.append('</table>')