Lutris: Add some util functions for conditional game list parsing #364
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some readability improvements that may help extending these checks later for future work, hopefully not too premature! 😄
When I was digging into #363 I noticed that some of the conditional logic was a bit long and seemingly arbitrary. To help with readability I made some generic utility functions that should explain better than the checks we were doing before.
For #363 we may need to extend the conditional logic i.e. in
pupgui2ctinfodialog.py
, we may need to add a check for whether a given runtime is in use. This would get pretty long, but with this format, we could makeis_lutris_game_using_runtime('dxvk', game.dxvk_version)
(or something along these lines, idk how we would want to do this just yet, and not too important for this PR :-) ).The first function added is to check what runner a
LutrisGame
is using, withnot None
and length sanity checks. We were already doing this for the Games List(
ProtonUp-Qt/pupgui2/pupgui2gamelistdialog.py
Line 178 in 6cf1def
But this function now means anytime we check the runner name, we perform these checks.
The 2nd function is more specific, and it checks if a
LutrisGame
is using Wine as its runner, with an optional parameter to check if it's using a specific Wine version. I figured there's no harm in making this function a bit more flexible as it was pretty straightforward to extend.This could make our checks a lot cleaner should they be extended further. At least in my opinion,
if is_lutris_game_using_wine(game, self.ctool.displayname) or is_lutris_game_using_runtime(game, ...)
is a lot cleaner than extending our existing check.