Skip to content

Commit

Permalink
Use correct sys.platform convention
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Jan 28, 2025
1 parent a6325e7 commit 77d7572
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
25 changes: 13 additions & 12 deletions cartridges/importer/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def game_id_format(self) -> str:

@property
def is_available(self) -> bool:
return sys.platform in self.available_on
return any(sys.platform.startswith(platform) for platform in self.available_on)

def make_executable(self, *args, **kwargs) -> str:
"""
Expand Down Expand Up @@ -120,14 +120,15 @@ class URLExecutableSource(ExecutableFormatSource):

@property
def executable_format(self) -> str:
match sys.platform:
case "win32":
return "start " + self.url_format
case "linux":
return "xdg-open " + self.url_format
case "darwin":
return "open " + self.url_format
case other:
raise NotImplementedError(
f"No URL handler command available for {other}"
)
if sys.platform.startswith("win32"):
return f"start {self.url_format}"

if sys.platform.startswith("linux"):
return f"xdg-open {self.url_format}"

if sys.platform.startswith("darwin"):
return f"open {self.url_format}"

raise NotImplementedError(
f"No URL handler command available for {sys.platform}"
)
6 changes: 3 additions & 3 deletions cartridges/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from cartridges.utils.run_executable import run_executable
from cartridges.window import CartridgesWindow

if sys.platform == "darwin":
if sys.platform.startswith("darwin"):
from AppKit import NSApp # type: ignore
from PyObjCTools import AppHelper

Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self) -> None:

self.add_main_option_entries((search, launch))

if sys.platform == "darwin":
if sys.platform.startswith("darwin"):
if settings := Gtk.Settings.get_default():
settings.props.gtk_decoration_layout = "close,minimize,maximize:"

Expand Down Expand Up @@ -405,7 +405,7 @@ def create_actions(self, actions: set) -> None:
f"app.{action[0]}" if scope == self else f"win.{action[0]}",
(
tuple(s.replace("<primary>", "<meta>") for s in action[1])
if sys.platform == "darwin"
if sys.platform.startswith("darwin")
else action[1]
),
)
Expand Down

0 comments on commit 77d7572

Please sign in to comment.