From 1a402fe02469aa1a414f62e7d5a620b3dac422d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Mon, 6 May 2024 17:17:03 +0200 Subject: [PATCH] Remove deprecated pkg_resources, replace with importlib references QubesOS/qubes-issues#9195 --- qrexec/tools/qrexec_policy_agent.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qrexec/tools/qrexec_policy_agent.py b/qrexec/tools/qrexec_policy_agent.py index dc836a2c..fb92a423 100644 --- a/qrexec/tools/qrexec_policy_agent.py +++ b/qrexec/tools/qrexec_policy_agent.py @@ -28,7 +28,7 @@ import argparse import asyncio -import pkg_resources +import importlib.resources # pylint: disable=import-error,wrong-import-position import gi @@ -322,9 +322,9 @@ def can_perform_action(self): class RPCConfirmationWindow: # pylint: disable=too-few-public-methods,too-many-instance-attributes - _source_file = pkg_resources.resource_filename( - "qrexec", os.path.join("glade", "RPCConfirmationWindow.glade") - ) + _source_file_ref = importlib.resources.files("qrexec").joinpath( + os.path.join("glade", "RPCConfirmationWindow.glade")) + _source_id = { "window": "RPCConfirmationWindow", "ok": "okButton", @@ -429,7 +429,8 @@ def __init__( sanitize_service_name(source, assert_sanitized=True) self._gtk_builder = Gtk.Builder() - self._gtk_builder.add_from_file(self._source_file) + with importlib.resources.as_file(self._source_file_ref) as path: + self._gtk_builder.add_from_file(str(path)) self._rpc_window = self._gtk_builder.get_object( self._source_id["window"] )