Skip to content

Commit

Permalink
Remove deprecated pkg_resources, replace with importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarta committed May 6, 2024
1 parent 652b8f5 commit 1a402fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions qrexec/tools/qrexec_policy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import argparse
import asyncio

import pkg_resources
import importlib.resources

# pylint: disable=import-error,wrong-import-position
import gi
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"]
)
Expand Down

0 comments on commit 1a402fe

Please sign in to comment.