Debian Codegraph @

src/app_model/types/_constants.py

raw
1 import os
2 import sys
3 from enum import Enum, IntEnum
4
5
6 class KeyBindingSource(IntEnum):
7 """Keybinding source enum."""
8
9 APP = 0
10 PLUGIN = 1
11 USER = 2
12
13
14 class OperatingSystem(Enum):
15 """Operating system enum."""
16
17 UNKNOWN = 0
18 WINDOWS = 1
19 MACOS = 2
20 LINUX = 3
21
22 @staticmethod
23 def current() -> "OperatingSystem":
24 """Return the current operating system as enum."""
25 return _CURRENT
26
27 @property
28 def is_windows(self) -> bool:
29 """Returns True if the current operating system is Windows."""
30 return _CURRENT == OperatingSystem.WINDOWS
31
32 @property
33 def is_linux(self) -> bool:
34 """Returns True if the current operating system is Linux."""
35 return _CURRENT == OperatingSystem.LINUX
36
37 @property
38 def is_mac(self) -> bool:
39 """Returns True if the current operating system is MacOS."""
40 return _CURRENT == OperatingSystem.MACOS
41
42
43 _CURRENT = OperatingSystem.UNKNOWN
44 if os.name == "nt":
45 _CURRENT = OperatingSystem.WINDOWS
46 if sys.platform.startswith("linux"):
47 _CURRENT = OperatingSystem.LINUX
48 elif sys.platform == "darwin":
49 _CURRENT = OperatingSystem.MACOS