Conditions | 6 |
Total Lines | 18 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import plistlib |
||
24 | def detect(data: dict | None = None) -> str: |
||
25 | if data is None: |
||
26 | if PREFERENCES.exists(): |
||
27 | with PREFERENCES.open("rb") as fp: |
||
28 | data = plistlib.load(fp) |
||
29 | else: |
||
30 | log.debug(f"File not found: {PREFERENCES}") |
||
31 | data = {} |
||
32 | |||
33 | for handler in data.get("LSHandlers", []): |
||
34 | if handler.get("LSHandlerURLScheme") == "http": |
||
35 | role = handler["LSHandlerRoleAll"] |
||
36 | name = NAMES[role] |
||
37 | log.info(f"Detected default browser: {name}") |
||
38 | return name |
||
39 | |||
40 | log.warn("Unable to determine the default browser") |
||
41 | return DEFAULT |
||
42 | |||
47 |