Replace regular expression grep of desktop file with the Gio API for this.

This commit is contained in:
Daniel Johnson 2024-02-28 19:14:18 -05:00
parent 67c0f807e9
commit 467993d41a

View file

@ -166,12 +166,11 @@ class XDGGame(ServiceGame):
@staticmethod
def get_desktop_entry_path(xdg_app):
"""Retrieve the Path variable from the .desktop file"""
desktop_entry = xdg_app.get_filename()
with open(desktop_entry, 'r') as f:
contents = f.read()
match = re.search(r'^Path=(.*)$', contents, re.MULTILINE)
if match:
return match.group(1)
# I expect we'll only see DesktopAppInfos here, but just in case
# we get something else, we'll make sure.
if hasattr(xdg_app, "get_string"):
return xdg_app.get_string("Path")
return None
@staticmethod