|
36 | 36 | from . import profileUpgrader
|
37 | 37 | from . import aggregatedSection
|
38 | 38 | from .configSpec import confspec
|
39 |
| -from .configFlags import OutputMode |
40 | 39 | from .featureFlag import (
|
41 | 40 | _transformSpec_AddFeatureFlagDefault,
|
42 | 41 | _validateConfig_featureFlag,
|
|
49 | 48 | Set,
|
50 | 49 | Tuple,
|
51 | 50 | )
|
52 |
| -from addonAPIVersion import BACK_COMPAT_TO |
53 | 51 | import NVDAState
|
54 | 52 | from NVDAState import WritePaths
|
55 | 53 |
|
@@ -1306,74 +1304,37 @@ def __setitem__(
|
1306 | 1304 | self.manager._markWriteProfileDirty()
|
1307 | 1305 | self._cache[key] = val
|
1308 | 1306 |
|
1309 |
| - # Alias ["documentFormatting"]["reportFontAttributes"] and ["speech"]["includeCLDR"] |
1310 |
| - # for backwards compatibility. |
1311 |
| - # TODO: Comment out in 2025.1. |
1312 |
| - if BACK_COMPAT_TO < (2025, 1, 0) and NVDAState._allowDeprecatedAPI(): |
1313 |
| - self._linkDeprecatedValues(key, val) |
| 1307 | + # Alias old config items to their new counterparts for backwards compatibility. |
| 1308 | + # Uncomment when there are new links that need to be made. |
| 1309 | + # if BACK_COMPAT_TO < (2026, 1, 0) and NVDAState._allowDeprecatedAPI(): |
| 1310 | + # self._linkDeprecatedValues(key, val) |
1314 | 1311 |
|
1315 | 1312 | def _linkDeprecatedValues(self, key: aggregatedSection._cacheKeyT, val: aggregatedSection._cacheValueT):
|
1316 | 1313 | """Link deprecated config keys and values to their replacements.
|
1317 | 1314 |
|
1318 |
| - Args: |
1319 |
| - key: The configuration key to link to its new or old counterpart. |
1320 |
| - val: The value associated with the configuration key. |
1321 |
| -
|
1322 |
| - postconditions: |
1323 |
| - - If self.path is "documentFormatting": |
1324 |
| - - If key is "reportFontAttributes": |
1325 |
| - - If val is True, "documentFormatting.fontAttributeReporting" is set to OutputMode.SPEECH_AND_BRAILLE, otherwise, it is set to OutputMode.OFF. |
1326 |
| - - If key is "fontAttributeReporting": |
1327 |
| - - if val is OutputMode.OFF, "documentFormatting.reportFontAttributes" is set to False, otherwise, it is set to True. |
| 1315 | + :arg key: The configuration key to link to its new or old counterpart. |
| 1316 | + :arg val: The value associated with the configuration key. |
| 1317 | +
|
| 1318 | + Example of how to link values: |
| 1319 | +
|
| 1320 | + >>> match self.path: |
| 1321 | + >>> ... |
| 1322 | + >>> case ("path", "segments"): |
| 1323 | + >>> ... |
| 1324 | + >>> match key: |
| 1325 | + >>> case "newKey": |
| 1326 | + >>> # Do something to alias the new path/key to the old path/key for backwards compatibility. |
| 1327 | + >>> case "oldKey": |
| 1328 | + >>> # Do something to alias the old path/key to the new path/key for forwards compatibility. |
| 1329 | + >>> case _: |
| 1330 | + >>> # We don't care about other keys in this section. |
| 1331 | + >>> return |
| 1332 | + >>> case _: |
| 1333 | + >>> # We don't care about other sections. |
| 1334 | + >>> return |
| 1335 | + >>> ... |
1328 | 1336 | """
|
1329 | 1337 | match self.path:
|
1330 |
| - case ("documentFormatting",): |
1331 |
| - match key: |
1332 |
| - case "fontAttributeReporting": |
1333 |
| - # Alias documentFormatting.fontAttributeReporting to documentFormatting.reportFontAttributes for backwards compatibility. |
1334 |
| - key = "reportFontAttributes" |
1335 |
| - val = bool(val) |
1336 |
| - |
1337 |
| - case "reportFontAttributes": |
1338 |
| - # Alias documentFormatting.reportFontAttributes to documentFormatting.fontAttributeReporting for forwards compatibility. |
1339 |
| - log.warning( |
1340 |
| - "documentFormatting.reportFontAttributes is deprecated. Use documentFormatting.fontAttributeReporting instead.", |
1341 |
| - # Include stack info so testers can report warning to add-on author. |
1342 |
| - stack_info=True, |
1343 |
| - ) |
1344 |
| - key = "fontAttributeReporting" |
1345 |
| - val = OutputMode.SPEECH_AND_BRAILLE if val else OutputMode.OFF |
1346 |
| - |
1347 |
| - case _: |
1348 |
| - # We don't care about other keys in this section. |
1349 |
| - return |
1350 |
| - |
1351 |
| - case ("speech",): |
1352 |
| - match key: |
1353 |
| - case "symbolDictionaries": |
1354 |
| - # Alias speech.symbolDictionaries to speech.includeCLDR for backwards compatibility. |
1355 |
| - key = "includeCLDR" |
1356 |
| - val = "cldr" in val |
1357 |
| - |
1358 |
| - case "includeCLDR": |
1359 |
| - # Alias speech.includeCLDR to speech.symbolDictionaries for forwards compatibility. |
1360 |
| - log.warning( |
1361 |
| - "speech.includeCLDR is deprecated. Use speech.symbolDictionaries instead.", |
1362 |
| - # Include stack info so testers can report warning to add-on author. |
1363 |
| - stack_info=True, |
1364 |
| - ) |
1365 |
| - key = "symbolDictionaries" |
1366 |
| - curVal = self.get(key, []).copy() |
1367 |
| - if val and "cldr" not in curVal: |
1368 |
| - curVal.append("cldr") |
1369 |
| - elif not val and "cldr" in curVal: |
1370 |
| - curVal.remove("cldr") |
1371 |
| - val = curVal |
1372 |
| - |
1373 |
| - case _: |
1374 |
| - # We don't care about other keys in this section. |
1375 |
| - return |
1376 |
| - |
1377 | 1338 | case _:
|
1378 | 1339 | # We don't care about other sections.
|
1379 | 1340 | return
|
|
0 commit comments