Merge ~mitya57/compiz:python3.8 into compiz:master

Proposed by Dmitry Shachnev
Status: Merged
Approved by: Dmitry Shachnev
Approved revision: 9b2b4ee050b28a6805fa9f86f721a5210dd55d7d
Merged at revision: 91d70986b2ffe33c351c60e954cd03dc4d235564
Proposed branch: ~mitya57/compiz:python3.8
Merge into: compiz:master
Diff against target: 149 lines (+11/-17)
4 files modified
compizconfig/ccsm/ccm/Pages.py (+2/-4)
compizconfig/ccsm/ccm/Settings.py (+5/-7)
compizconfig/ccsm/ccm/Utils.py (+3/-4)
compizconfig/ccsm/ccm/Widgets.py (+1/-2)
Reviewer Review Type Date Requested Status
Alberts Muktupāvels Approve
Compiz Maintainers Pending
Review via email: mp+375644@code.launchpad.net

Commit message

Use GLib.markup_escape_text instead of cgi.escape which was removed in Python 3.8.

Description of the change

I replaced all uses of cgi.escape with GLib.markup_escape_text.

Another solution would be using html.escape, but there is no need for extra import when GLib contains a function specifically designed for GMarkup (which Pango uses).

To post a comment you must log in.
Revision history for this message
Alberts Muktupāvels (muktupavels) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/compizconfig/ccsm/ccm/Pages.py b/compizconfig/ccsm/ccm/Pages.py
2index 6bab061..f915c8d 100644
3--- a/compizconfig/ccsm/ccm/Pages.py
4+++ b/compizconfig/ccsm/ccm/Pages.py
5@@ -33,8 +33,6 @@ from ccm.Conflicts import PluginConflict
6 from ccm.Utils import gtk_process_events, getScreens, Image, PrettyButton, Label, NotFoundBox, GlobalUpdater, CategoryKeyFunc, GroupIndexKeyFunc, PluginKeyFunc, GetSettings, GetAcceleratorName
7 from ccm.Widgets import ClearEntry, PluginView, GroupView, SelectorButtons, ScrolledList, Popup, KeyGrabber, AboutDialog, PluginWindow
8
9-from cgi import escape as protect_pango_markup
10-
11 import os
12
13 import locale
14@@ -397,7 +395,7 @@ class FilterPage(GenericPage):
15 for index, n in enumerate(context.Plugins):
16 plugin = context.Plugins[n]
17 bar.set_fraction((index+1)/float(length))
18- label.set_markup("<i>%s</i>" %protect_pango_markup(plugin.ShortDesc))
19+ label.set_markup("<i>%s</i>" % GLib.markup_escape_text(plugin.ShortDesc))
20 gtk_process_events()
21
22 groups = []
23@@ -1383,7 +1381,7 @@ class GroupPage(Page):
24 self.VisibleAreas = self.subGroupAreas = []
25 self.Label = Gtk.Alignment(xalign=0.0, yalign=0.5)
26 self.Label.set_padding(4, 4, 4, 4)
27- label = Gtk.Label(label="<b>%s</b>" % (protect_pango_markup(name or _('General'))))
28+ label = Gtk.Label(label="<b>%s</b>" % (GLib.markup_escape_text(name or _('General'))))
29 label.set_use_markup(True)
30 label.set_xalign(0.0)
31 self.Label.add(label)
32diff --git a/compizconfig/ccsm/ccm/Settings.py b/compizconfig/ccsm/ccm/Settings.py
33index ec498a9..0f5104f 100644
34--- a/compizconfig/ccsm/ccm/Settings.py
35+++ b/compizconfig/ccsm/ccm/Settings.py
36@@ -29,8 +29,6 @@ from ccm.Conflicts import KeyConflict, ButtonConflict, EdgeConflict
37 from ccm.Widgets import CellRendererColor, ModifierSelector, SingleEdgeSelector, KeyGrabber, MatchButton, FileButton, ErrorDialog
38 from ccm.Utils import Image, ActionImage, SizedButton, GlobalUpdater, PureVirtualError, SettingKeyFunc, EnumSettingKeyFunc, HasOnlyType, GetSettings, GetAcceleratorName
39
40-from cgi import escape as protect_pango_markup
41-
42 import locale
43 import gettext
44 locale.setlocale(locale.LC_ALL, "")
45@@ -110,7 +108,7 @@ class Setting(object):
46 return
47
48 label = Gtk.Label()
49- desc = protect_pango_markup (self.Setting.ShortDesc)
50+ desc = GLib.markup_escape_text(self.Setting.ShortDesc)
51 style = "%s"
52 if self.Setting.Integrated:
53 style = "<i>%s</i>"
54@@ -966,7 +964,7 @@ class KeySetting (EditableActionSetting):
55 def HandleDialogText (self, accel):
56 name = self.ReorderKeyString (accel)
57 if len (accel) != len (name):
58- accel = protect_pango_markup (accel)
59+ accel = GLib.markup_escape_text(accel)
60 ErrorDialog (self.Widget.get_toplevel (),
61 _("\"%s\" is not a valid shortcut") % accel)
62 return
63@@ -1149,7 +1147,7 @@ class ButtonSetting (EditableActionSetting):
64
65 def HandleDialogText (self, button):
66 def ShowErrorDialog (button):
67- button = protect_pango_markup (button)
68+ button = GLib.markup_escape_text(button)
69 ErrorDialog (self.Widget.get_toplevel (),
70 _("\"%s\" is not a valid button") % button)
71 if button.lower ().strip () in ("", "disabled", "none"):
72@@ -1276,7 +1274,7 @@ class ButtonSetting (EditableActionSetting):
73 buttons = Gtk.ButtonsType.YES_NO,
74 title = _("Warning"))
75
76- warning.set_markup (GLib.markup_escape_text (_("Using Button1 without modifiers can \
77+ warning.set_markup(GLib.markup_escape_text(_("Using Button1 without modifiers can \
78 prevent any left click and thus break your configuration. Do you really want \
79 to set \"%s\" button to Button1 ?") % self.Setting.ShortDesc))
80
81@@ -1330,7 +1328,7 @@ class EdgeSetting (EditableActionSetting):
82 valid = False
83 break
84 if not valid:
85- mask = protect_pango_markup (mask)
86+ mask = GLib.markup_escape_text(mask)
87 ErrorDialog (self.Widget.get_toplevel (),
88 _("\"%s\" is not a valid edge mask") % mask)
89 return
90diff --git a/compizconfig/ccsm/ccm/Utils.py b/compizconfig/ccsm/ccm/Utils.py
91index 58be28a..1040bb9 100644
92--- a/compizconfig/ccsm/ccm/Utils.py
93+++ b/compizconfig/ccsm/ccm/Utils.py
94@@ -27,7 +27,6 @@ from gi.repository import GObject
95 import weakref
96
97 from ccm.Constants import ImageNone, ImagePlugin, ImageCategory, ImageThemed, ImageStock, DataDir, IconDir
98-from cgi import escape as protect_pango_markup
99 import operator
100
101 import locale
102@@ -57,7 +56,7 @@ def getDefaultScreen():
103 return Gdk.Screen.get_default().get_number()
104
105 def protect_markup_dict (dict_):
106- return dict((k, protect_pango_markup (v)) for (k, v) in dict_.items())
107+ return {k: GLib.markup_escape_text(v) for k, v in dict_.items()}
108
109 class Image (Gtk.Image):
110
111@@ -187,7 +186,7 @@ class NotFoundBox(Gtk.Alignment):
112 box = Gtk.HBox()
113 self.Warning = Gtk.Label()
114 self.Markup = _("<span size=\"large\"><b>No matches found.</b> </span><span>\n\n Your filter \"<b>%s</b>\" does not match any items.</span>")
115- value = protect_pango_markup(value)
116+ value = GLib.markup_escape_text(value)
117 self.Warning.set_markup(self.Markup % value)
118 image = Image("face-surprise", ImageThemed, 48)
119
120@@ -196,7 +195,7 @@ class NotFoundBox(Gtk.Alignment):
121 self.add(box)
122
123 def update(self, value):
124- value = protect_pango_markup(value)
125+ value = GLib.markup_escape_text(value)
126 self.Warning.set_markup(self.Markup % value)
127
128 class IdleSettingsParser:
129diff --git a/compizconfig/ccsm/ccm/Widgets.py b/compizconfig/ccsm/ccm/Widgets.py
130index 47b88a6..9e24d1d 100644
131--- a/compizconfig/ccsm/ccm/Widgets.py
132+++ b/compizconfig/ccsm/ccm/Widgets.py
133@@ -27,7 +27,6 @@ from gi.repository import GObject
134 from gi.repository import PangoCairo
135 from gi.repository import GdkPixbuf
136 import cairo
137-from cgi import escape as protect_pango_markup
138 from math import pi, sqrt
139 import time
140 import os
141@@ -295,7 +294,7 @@ class SelectorBox(Gtk.ScrolledWindow):
142 def add_item(self, item, callback, markup="%s", image=None, info=None):
143 button = Gtk.Button()
144 label = Label(wrap=170)
145- text = protect_pango_markup(item)
146+ text = GLib.markup_escape_text(item)
147 label.set_markup(markup % text or _("General"))
148 labelBox = Gtk.VBox()
149 labelBox.set_spacing(5)

Subscribers

People subscribed via source and target branches