!27 update version to 3.3.32
From: @zgzxx Reviewed-by: @HuaxinLuGitee, @huangzq6 Signed-off-by: @HuaxinLuGitee, @huangzq6
This commit is contained in:
commit
a212abe8e7
@ -1,161 +0,0 @@
|
||||
From 838f53a97ce44ea0f8f4d361afcb62a441f8633f Mon Sep 17 00:00:00 2001
|
||||
From: Adam Williamson <awilliam@redhat.com>
|
||||
Date: Mon, 26 Jul 2021 13:11:17 -0700
|
||||
Subject: [PATCH] Considerably simplify html_util for Python 3.10
|
||||
compatibility (#58)
|
||||
|
||||
As reported in #58 and RHBZ #1972391, `formatter` was removed
|
||||
from the Python standard library in Python 3.10. This heavily
|
||||
simplifies `html_util.html_to_text()` by using the stdlib
|
||||
`HTMLParser` class, which avoids the use of `formatter`.
|
||||
|
||||
Signed-off-by: Adam Williamson <awilliam@redhat.com>
|
||||
---
|
||||
src/setroubleshoot/html_util.py | 110 ++++----------------------------
|
||||
1 file changed, 12 insertions(+), 98 deletions(-)
|
||||
|
||||
diff --git a/src/setroubleshoot/html_util.py b/src/setroubleshoot/html_util.py
|
||||
index 5c6d07a..095eaeb 100644
|
||||
--- a/src/setroubleshoot/html_util.py
|
||||
+++ b/src/setroubleshoot/html_util.py
|
||||
@@ -28,110 +28,29 @@ __all__ = [
|
||||
|
||||
import syslog
|
||||
import sys
|
||||
+import textwrap
|
||||
if sys.version_info > (3,):
|
||||
import html
|
||||
- import html.parser
|
||||
import html.entities
|
||||
- from io import StringIO
|
||||
+ from html.parser import HTMLParser
|
||||
else:
|
||||
import htmllib
|
||||
- from StringIO import StringIO
|
||||
-import formatter as Formatter
|
||||
+ from HTMLParser import HTMLParser
|
||||
import string
|
||||
from types import *
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
+class HTMLFilter(HTMLParser):
|
||||
+ def __init__(self):
|
||||
+ HTMLParser.__init__(self)
|
||||
+ self.text = ""
|
||||
|
||||
-class TextWriter(Formatter.DumbWriter):
|
||||
-
|
||||
- def __init__(self, file=None, maxcol=80, indent_width=4):
|
||||
- Formatter.DumbWriter.__init__(self, file, maxcol)
|
||||
- self.indent_level = 0
|
||||
- self.indent_width = indent_width
|
||||
- self._set_indent()
|
||||
-
|
||||
- def _set_indent(self):
|
||||
- self.indent_col = self.indent_level * self.indent_width
|
||||
- self.indent = ' ' * self.indent_col
|
||||
-
|
||||
- def new_margin(self, margin, level):
|
||||
- self.indent_level = level
|
||||
- self._set_indent()
|
||||
-
|
||||
- def send_label_data(self, data):
|
||||
- data = data + ' '
|
||||
- if len(data) > self.indent_col:
|
||||
- self.send_literal_data(data)
|
||||
- else:
|
||||
- offset = self.indent_col - len(data)
|
||||
- self.send_literal_data(' ' * offset + data)
|
||||
-
|
||||
- def send_flowing_data(self, data):
|
||||
- if not data:
|
||||
- return
|
||||
- atbreak = self.atbreak or data[0] in string.whitespace
|
||||
- col = self.col
|
||||
- maxcol = self.maxcol
|
||||
- write = self.file.write
|
||||
- col = self.col
|
||||
- if col == 0:
|
||||
- write(self.indent)
|
||||
- col = self.indent_col
|
||||
- for word in data.split():
|
||||
- if atbreak:
|
||||
- if col + len(word) >= maxcol:
|
||||
- write('\n' + self.indent)
|
||||
- col = self.indent_col
|
||||
- else:
|
||||
- write(' ')
|
||||
- col = col + 1
|
||||
- write(word)
|
||||
- col = col + len(word)
|
||||
- atbreak = 1
|
||||
- self.col = col
|
||||
- self.atbreak = data[-1] in string.whitespace
|
||||
-
|
||||
-if sys.version_info > (3,):
|
||||
- class HTMLParserAnchor(html.parser.HTMLParser):
|
||||
-
|
||||
- def __init__(self, formatter, strict=False, convert_charrefs=False):
|
||||
- super(HTMLParserAnchor, self).__init__()
|
||||
- self.formatter = formatter
|
||||
- self.anchor_href = None
|
||||
-
|
||||
- def handle_starttag(self, tag, attrs):
|
||||
- if tag == 'a':
|
||||
- for key, value in attrs:
|
||||
- if key == 'href':
|
||||
- self.anchor_href = value
|
||||
-
|
||||
- def handle_endtag(self, tag):
|
||||
- if tag == 'a':
|
||||
- if self.anchor_href != None:
|
||||
- self.formatter.writer.send_flowing_data('(' + self.anchor_href + ')')
|
||||
- self.anchor_href = None
|
||||
-
|
||||
- def handle_data(self, data):
|
||||
- self.formatter.writer.send_flowing_data(data)
|
||||
-
|
||||
-else:
|
||||
- class HTMLParserAnchor(htmllib.HTMLParser):
|
||||
-
|
||||
- def __init__(self, formatter, verbose=0):
|
||||
- htmllib.HTMLParser.__init__(self, formatter, verbose)
|
||||
-
|
||||
- def anchor_bgn(self, href, name, type):
|
||||
- self.anchor = href
|
||||
-
|
||||
- def anchor_end(self):
|
||||
- if self.anchor:
|
||||
- self.handle_data(' (%s) ' % self.anchor)
|
||||
- self.anchor = None
|
||||
+ def handle_data(self, data):
|
||||
+ self.text += data
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
-
|
||||
def escape_html(s):
|
||||
if s is None:
|
||||
return None
|
||||
@@ -161,14 +80,9 @@ def unescape_html(s):
|
||||
|
||||
def html_to_text(html, maxcol=80):
|
||||
try:
|
||||
- buffer = StringIO()
|
||||
- formatter = Formatter.AbstractFormatter(TextWriter(buffer, maxcol))
|
||||
- parser = HTMLParserAnchor(formatter)
|
||||
- parser.feed(html)
|
||||
- parser.close()
|
||||
- text = buffer.getvalue()
|
||||
- buffer.close()
|
||||
- return text
|
||||
+ filter = HTMLFilter()
|
||||
+ filter.feed(html)
|
||||
+ return textwrap.fill(filter.text, width=maxcol)
|
||||
except Exception as e:
|
||||
syslog.syslog(syslog.LOG_ERR, 'cannot convert html to text: %s' % e)
|
||||
return None
|
||||
--
|
||||
2.27.0
|
||||
|
||||
Binary file not shown.
BIN
setroubleshoot-3.3.32.tar.gz
Normal file
BIN
setroubleshoot-3.3.32.tar.gz
Normal file
Binary file not shown.
@ -1,20 +1,18 @@
|
||||
Name: setroubleshoot
|
||||
Version: 3.3.26
|
||||
Version: 3.3.32
|
||||
Release: 1
|
||||
Summary: SELinux Trouble Shooting Tool
|
||||
License: GPLv2+
|
||||
URL: https://pagure.io/setroubleshoot
|
||||
URL: https://gitlab.com/setroubleshoot/setroubleshoot
|
||||
|
||||
Source0: https://releases.pagure.org/setroubleshoot/%{name}-%{version}.tar.gz
|
||||
Source0: https://gitlab.com/setroubleshoot/setroubleshoot/-/archive/%{version}/%{name}-%{version}.tar.gz
|
||||
Source1: %{name}.tmpfiles
|
||||
|
||||
Patch1: backport-Considerably-simplify-html_util-for-Python-3.10-comp.patch
|
||||
|
||||
Patch9000: Fix-config-file-to-deny-noraml-user-to-stop-Setroubleshootd.patch
|
||||
|
||||
BuildRequires: gcc libcap-ng-devel intltool gettext python3 python3-devel
|
||||
BuildRequires: desktop-file-utils dbus-glib-devel gtk2-devel libnotify-devel audit-libs-devel libselinux-devel polkit-devel
|
||||
BuildRequires: python3-libselinux python3-dasbus python3-gobject gtk3-devel xdg-utils
|
||||
BuildRequires: python3-libselinux python3-dasbus python3-gobject gtk3-devel xdg-utils python3-pip
|
||||
|
||||
Requires: %{name}-server = %{version}-%{release}
|
||||
Requires: gtk3, libnotify libreport python3-libreport python3-gobject python3-dasbus xdg-utils
|
||||
@ -66,6 +64,7 @@ SELinux troubleshoot legacy applet
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
|
||||
%build
|
||||
./autogen.sh
|
||||
%global _python_bytecompile_extra 0
|
||||
%configure PYTHON=%{__python3} --enable-seappletlegacy=yes --with-auditpluginsdir=/etc/audit/plugins.d
|
||||
%make_build V=1
|
||||
@ -107,8 +106,8 @@ chown -R setroubleshoot:setroubleshoot %{_localstatedir}/lib/%{name}
|
||||
%config(noreplace) %{_sysconfdir}/xdg/autostart/*
|
||||
%{_datadir}/%{name}/gui
|
||||
%{_datadir}/applications/*.desktop
|
||||
%{_datadir}/appdata/*.appdata.xml
|
||||
%{_datadir}/dbus-1/services/sealert.service
|
||||
%{_datadir}/metainfo/*.appdata.xml
|
||||
%{_datadir}/dbus-1/services/org.fedoraproject.sealert.service
|
||||
%{_datadir}/icons/hicolor/*/*/*
|
||||
%dir %attr(0755,root,root) %{python3_sitelib}/%{name}
|
||||
%{python3_sitelib}/%{name}/browser.py
|
||||
@ -120,7 +119,7 @@ chown -R setroubleshoot:setroubleshoot %{_localstatedir}/lib/%{name}
|
||||
%{_bindir}/sealert
|
||||
%{_sbindir}/sedispatch
|
||||
%{_sbindir}/setroubleshootd
|
||||
%{python3_sitelib}/setroubleshoot*.egg-info
|
||||
%{python3_sitelib}/setroubleshoot*.dist-info
|
||||
%dir %attr(0755,root,root) %{_sysconfdir}/%{name}
|
||||
%dir %{python3_sitelib}/%{name}
|
||||
%dir %{python3_sitelib}/%{name}/__pycache__
|
||||
@ -140,6 +139,7 @@ chown -R setroubleshoot:setroubleshoot %{_localstatedir}/lib/%{name}
|
||||
%ghost %attr(0600,setroubleshoot,setroubleshoot) %{_localstatedir}/lib/%{name}/setroubleshoot_database.xml
|
||||
%ghost %attr(0644,setroubleshoot,setroubleshoot) %{_localstatedir}/lib/%{name}/email_alert_recipients
|
||||
%config /etc/audit/plugins.d/sedispatch.conf
|
||||
%{_unitdir}/setroubleshootd.service
|
||||
%{_datadir}/dbus-1/system-services/org.fedoraproject.Setroubleshootd.service
|
||||
%{_datadir}/dbus-1/system-services/org.fedoraproject.SetroubleshootPrivileged.service
|
||||
%{_datadir}/polkit-1/actions/org.fedoraproject.setroubleshootfixit.policy
|
||||
@ -160,6 +160,9 @@ chown -R setroubleshoot:setroubleshoot %{_localstatedir}/lib/%{name}
|
||||
%{_mandir}/man1/seapplet.1.gz
|
||||
|
||||
%changelog
|
||||
* Thu Jul 20 2023 zhangguangzhi <zhangguangzhi3@huawei.com> - 3.3.32-1
|
||||
- update version to 3.3.32
|
||||
|
||||
* Mon Jan 30 2023 wangyunjia <yunjia.wang@huawei.com> - 3.3.26-1
|
||||
- update version to 3.3.26
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user