Custom braille tables (#3304)#10172
Conversation
LeonarddeR
left a comment
There was a problem hiding this comment.
Thanks for this huge and nice work! I think I like the switch from json to configobj.
Now I wonder, have you considered storing table data in the add-ons manifest itself? I think this has a major benefit, namely that the add-on manifest parser has support for language inheritance out of the box. This means that coming up with the right translated name for the table is the responsibility of the potential add-on translator, not of the initial author.
| for addon in addonHandler.getRunningAddons(): | ||
| yield os.path.join(addon.path, "brailleTables") | ||
|
|
||
| return [dir_ for dir_ in candidates() if os.path.isdir(dir_)] |
There was a problem hiding this comment.
I like this style. Do you think it makes sense to log if the isdir check doesn't pass?
There was a problem hiding this comment.
I would guess no.
Having a file named "brailleTables" is damn unlikely, and no one would reasonably expect its content to be interpreted.
The check could even be removed here and such a file would still not break the resolver.
| ) | ||
|
|
||
|
|
||
| def _getCustomTableDisplayName(fileName: str, tableCfg: dict) -> str: |
There was a problem hiding this comment.
Have you considered making this a property on CustomTablesManifest?
There was a problem hiding this comment.
Actually, no.
The manifest is only one way to supply the config.
Another is to pass a dictionary to brailleTables.loadCustomTablesConfig (made public as of b87f5b2, see #10172 (comment))
Co-Authored-By: Leonard de Ruijter <leonardder@users.noreply.github.com>
Co-Authored-By: Leonard de Ruijter <leonardder@users.noreply.github.com>
You are very welcome. Thanks for you interest.
The add-on manifest could indeed safely contain a "brailleTables" section with the needed configuration. My concern, though, is that ConfigObj does not support formally optional sections. Anyway, an add-on can safely add a custom table during its initialization and have its display name translated as usual: Writing this I realize that EDIT: |
|
@feerrenrut, could your share your thoughts about what you think would be best to specify metadata for custom braille tables? |
|
@JulienCochuyt wrote:
Is this true? Is there anything holding you back from providing a [brailleTables] section and a [[many]] section in there and providing a manifest that doesn't have this section? I gess the validator would just add the empty section just as it adds defaults for optional fields, such as readme. |
It at least is how I understood DiffSK/configobj#131 back then: You can't have a specified optional section. Unspecified sections are supported, but once they are specified, they become mandatory. But anyhow, I doubt bundling a hundreds of tables in an add-on would ever be a reasonable use case, and keep in mind that registering the tables via simple code already allows translators to follow their usual workflow. |
Problem with this is that there are multiple pathways to do exactly the same. I'd rather have only one public method of bundling tables in add-ons. |
Actually, the support for metadata We're in Python, there isn't a single way to do things, even if a compatriot of yours is told to be the one able to distinguish which is the right one :) If I understand your point of view, it's hard to advertise the metadata |
Mm yes, this is an interesting one. This requires a method that doesn't involve add-on manifests.
This is true. However, I'd rather advertise one public method to do it, leaving it up to an add-on author to use another method that might be perfectly valid, but isn't the advised one. For example, if we decide that manifests is the way to go, add-on authors can still use the registration method, but they are encouraged to use the manifest method.
Yes, this is true. However, I think it is up to either @feerrenrut or @michaelDCurran to crack the nut here.
I'd say lets leave it as is until we have some more opinions about this. |
|
Could either @michaelDCurran and @feerrenrut elaborate on what NV access' standpoint is with regard to what implementation to use to define custom tables? See #10172 (comment) |
# Conflicts: # source/addonHandler/__init__.py # source/braille.py # source/brailleInput.py # source/brailleTables.py # source/gui/settingsDialogs.py
There was a problem hiding this comment.
when resolving this merge conflict, I kept this line where it currently is in master. However, it might need to get moved to handlePostConfigProfileSwitch?
There was a problem hiding this comment.
Why do you think it should be there? I don't think it needs to re-initialize after every config update?
There was a problem hiding this comment.
This was the only non-trivial change when resolving merge conflicts.
I thought was worth raising, in the case that we need to reload detections when changing braille tables.
feerrenrut
left a comment
There was a problem hiding this comment.
I'm going to need to come back to this next week.
| [brailleTables] | ||
| # The key is the table file name (not the full path) | ||
| [[__many__]] | ||
| displayName = string() |
There was a problem hiding this comment.
Is display name the name of the braille display, or the name of the braille table to be displayed in the GUI, or file name?
There was a problem hiding this comment.
This is the name displayed in the GUI. The [[many]] map key is the file name.
This is based on my understanding of the user docs: https://github.com/nvaccess/nvda/pull/10172/files#diff-c9a23ef91eea3598e1128c9564a3a9b511d4941456ca31a24837e81c18b8b5caR853-R868, and the code a little further down this file https://github.com/nvaccess/nvda/pull/10172/files#diff-2fafc40e2d44037b654b987d85ce3c62746cc62261eb9c8dd59268a2d48a9494R768-R771
There was a problem hiding this comment.
Why do you think it should be there? I don't think it needs to re-initialize after every config update?
|
How is it with this pull request? I think this would be useful feature. |
|
@JulienCochuyt any chance you can bring this forward? If not, I think you did some very valuable work here and I'm happy to take this one. I'll do that if I'm not hearing back from you within a month or so. |
This comment has been minimized.
This comment has been minimized.
|
@LeonarddeR I think @JulienCochuyt is no longer that active on Github, at least I didn't see any updates from him since many years. Are you still thinking about taking this up? |
|
Just a note, in my view unlike #3304 suggests, I would rather prefer an approach similar to speech dictionaries where user's dictionaries are stored in the user config and where users can edit the dictionaries in a GUI. . But I don't know if this is technically feasible. Nevertheless, this PR definitely would point things in the right direction at least. |
|
Hi - I'm going to mark this as a draft. I know that the reason this has been abandoned due to a delayed review from NV Access, however I do not see it in our near capacity to fix up the merge conflicts and prepare this for another review. |
|
I'm definitely taking this, since I might have a use case for myself in the near future. That's a pretty good stick behind the door if I may say so😉 |
|
Superseeded by #16208 |
Fixes #3304. Fixes #9863. Supersedes PR #9864, #10172. Addresses #505 (comment) Summary of the issue: In NVDA, there is no easy and reliable way for an add-on to provide a new braille table. For an experienced users wishing to do so there are two options: Alter manually an existing table in louis/tables. The new table still has its original name in the settings GUI. This change is lost upon NVDA updates. Set the absolute path to the table file in the configuration in lieu of the usual file name. The settings GUI shows an empty entry for this one. Forces to manually alter nvda.ini. Forces to copy in the same directory the whole dependency chain of the new table plus braille-patterns.cti. This is because liblouis default table resolver only looks for tables in a single directory, See Make it easier for add-ons to supply custom braille tables #5489 (comment) Description of how this pull request fixes the issue: Add a new brailleTables optional directory in both the user scratchpad directory and the add-on directory structure. Support reading tables metadata from an optional brailleTables section of the add-on manifest or from a manifest.ini file with the same format found in the root of the scratchpad directory, allowing a user to provide a display name and set output/input/contracted capabilities with no code. Implement a custom liblouis table resolver that resolves tables based on what is registered in the brailleTables module: When liblouis calls the resolver without a base file specified, the table is looked up from the brailleTables module and either resolved from the add-ons brailleTables directory or the built-in tables directory When liblouis calls the resolver with a base file specified (e.g. when processing includes in tables), the table is looked up from the folder of the base table and/or the built-in tables directory Enforce the existing fallback mechanism to ensure there still is braille output if the configured table cannot be found e.g. because an add-on or the scratchpad directory was disabled. This now applies both to the main configuration and individual profiles and also covers braille input. Note that if an add-on author wants a table to be listed in the GUI, he/she should always define the table in the manifest. Contrary to earlier incarnations of this pr, replacing a table in an add-on (i.e. when it has the same filename as a built-in table) without defining it in the manifest is no longer possible. Therefore it is also not possible to replace unlisted tables that are included by listed tables. For example, if you want to replace spaces.uti as included in nl-comp8.utb, you weel need to both define and bundle a replacement of nl-comp8.utb and spaces.uti in your add-on.
|
Since it has been superseded, I remove the "Abandoned" label. @seanbudd I hope NV Access approves such triage actions; it should allow to filter Abandoned PRs for somewone wanting to take it over. |
|
Thanks @CyrilleB79 |
Link to issue number:
Fixes #3304.
Fixes #9863.
Supersedes PR #9864.
Addresses #505 (comment)
Provides a workaround for #3470
Summary of the issue:
In NVDA, there is no easy and reliable way for an add-on to provide a new braille table.
For an experienced users wishing to do so there are two options:
louis/tables.The new table still has its original name in the settings GUI.
This change is lost upon NVDA updates.
The settings GUI shows an empty entry for this one.
Forces to manually alter
nvda.ini.Forces to copy in the same directory the whole dependency chain of the new table plus
braille-patterns.cti. This is because liblouis default table resolver only looks for tables in a single directory, See Make it easier for add-ons to supply custom braille tables #5489 (comment)Description of how this pull request fixes the issue:
brailleTablesoptional directory in both the user scratchpad directory and the add-on directory structure.louis/tables.brailleTablessection of the add-on manifest or from a.inifile with the same format found in thebrailleTablessubdirectory of the scratchpad directory, allowing a user to provide a display names and set output/input/contracted capabilities with no code.As is already the case in the default liblouis table resolver, table file names are treated as an identifier.
That is, if a user eg. provides in its
scratchpad/brailleTablesdirectory a new version of a table which is imported by other tables, all of those are impacted.Only one version of a given table file name can be resolved. In that concern, the user scratchpad directory takes precedence over add-ons, which take precedence over the tables provided with NVDA.
It also mean that the manifest file can alter metadata of a table file provided elsewhere.
Eg. adding a manifest to the
scratchpad/brailleTablesdirectory is enough to workaround #3470.Manifest file example as found in the developer guide:
Example add-on demonstrating the new functionality (please rename .zip to .nvda-addon):
pr10712-customBrailleTables-demo-2021.05.08.zip
Testing strategy:
From a source copy:
Known issues with pull request:
The current automatic translation of older tables names to newer tables names as of a liblouis update can lead to unexpected behavior if there is collision, but I do not think I am the one to take the decision when to drop this backward-compatibility piece.
Change log entry:
Section: Changes for developers
Add-on can now provide custom braille tables.
Code Review Checklist: