(self, user_data_dir)
| 38 | return a |
| 39 | |
| 40 | def handle_prefs(self, user_data_dir): |
| 41 | prefs = self.experimental_options.get("prefs") |
| 42 | if prefs: |
| 43 | user_data_dir = user_data_dir or self._user_data_dir |
| 44 | default_path = os.path.join(user_data_dir, "Default") |
| 45 | os.makedirs(default_path, exist_ok=True) |
| 46 | undot_prefs = {} |
| 47 | for key, value in prefs.items(): |
| 48 | undot_prefs = self._merge_nested( |
| 49 | undot_prefs, self._undot_key(key, value) |
| 50 | ) |
| 51 | prefs_file = os.path.join(default_path, "Preferences") |
| 52 | with suppress(Exception): |
| 53 | if os.path.exists(prefs_file): |
| 54 | with open( |
| 55 | prefs_file, encoding="utf-8", mode="r", errors="ignore" |
| 56 | ) as f: |
| 57 | undot_prefs = self._merge_nested( |
| 58 | json.load(f), undot_prefs |
| 59 | ) |
| 60 | with suppress(Exception): |
| 61 | with open( |
| 62 | prefs_file, encoding="utf-8", mode="w", errors="ignore" |
| 63 | ) as f: |
| 64 | json.dump(undot_prefs, f) |
| 65 | # Remove experimental_options to avoid errors |
| 66 | del self._experimental_options["prefs"] |
| 67 | exclude_switches = self.experimental_options.get("excludeSwitches") |
| 68 | if exclude_switches is not None: |
| 69 | del self._experimental_options["excludeSwitches"] |
| 70 | use_auto_ext = self.experimental_options.get("useAutomationExtension") |
| 71 | if use_auto_ext is not None: |
| 72 | del self._experimental_options["useAutomationExtension"] |
| 73 | |
| 74 | @classmethod |
| 75 | def from_options(cls, options): |
no test coverage detected