Skip to content

Commit

Permalink
Avoid deprecated pkg_resource API
Browse files Browse the repository at this point in the history
Replace it with Python 3.7+ importlib.
  • Loading branch information
DemiMarie committed Jan 14, 2024
1 parent e0f4598 commit bbc66c1
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 @@ -23,12 +23,11 @@
""" Agent running in user session, responsible for asking the user about policy
decisions."""

import importlib.resources
import itertools
import argparse
import asyncio

import pkg_resources

# pylint: disable=import-error,wrong-import-position
import gi

Expand Down Expand Up @@ -321,8 +320,8 @@ 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 = (
importlib.resources.files("qrexec") / "glade" / "RPCConfirmationWindow.glade"
)
_source_id = {
"window": "RPCConfirmationWindow",
Expand Down Expand Up @@ -428,7 +427,9 @@ def __init__(
sanitize_service_name(source, assert_sanitized=True)

self._gtk_builder = Gtk.Builder()
self._gtk_builder.add_from_file(self._source_file)
self._gtk_builder.add_from_string(
self._source_file.read_text(encoding="UTF-8", errors="strict")
)
self._rpc_window = self._gtk_builder.get_object(
self._source_id["window"]
)
Expand Down

0 comments on commit bbc66c1

Please sign in to comment.