Skip to content

Commit

Permalink
Minor config refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfioravanti committed Sep 2, 2024
1 parent 257641d commit 8e184e3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[MAIN]
ignored-modules=plover.machine.base,plover.registry,plover.engine,plover.formatting,plover.oslayer.config
ignored-modules =
plover.engine
plover.formatting
plover.machine.base
plover.oslayer.config
plover.registry
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ If you are a [`just`][] user, you may find the [`justfile`][] useful during
development in running multiple test commands. You can run the following command
from the project root directory:

```console
just --working-directory . --justfile test/justfile
```

### Deploying Changes

After making any code changes, deploy the plugin into Plover with the following
Expand Down
2 changes: 2 additions & 0 deletions plover_platform_specific_translation/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
load,
save
)
from .file import CONFIG_BASENAME

__all__ = [
"CONFIG_BASENAME",
"load",
"save"
]
2 changes: 2 additions & 0 deletions plover_platform_specific_translation/config/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
)


CONFIG_BASENAME: str = "platform_specific_translation.json"

def load(filepath: Path) -> dict[str, Any]:
"""
Reads in data from a JSON file
Expand Down
8 changes: 4 additions & 4 deletions plover_platform_specific_translation/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)


_CONFIG_FILEPATH: Path = Path(CONFIG_DIR) / "platform_specific_translation.json"
_CONFIG_FILE: Path = Path(CONFIG_DIR) / config.CONFIG_BASENAME

class PlatformSpecificTranslation:
"""
Expand All @@ -43,7 +43,7 @@ def start(self) -> None:
Sets up the meta plugin, steno engine hooks, and information to cache
"""
self._platform = platform.parse()
self._platform_translations = config.load(_CONFIG_FILEPATH)
self._platform_translations = config.load(_CONFIG_FILE)
registry.register_plugin(
"meta",
"PLATFORM",
Expand Down Expand Up @@ -88,7 +88,7 @@ def _platform_specific_translation(
self._platform_translations[argument] = (
(platform_translation_type, platform_translation)
)
config.save(_CONFIG_FILEPATH, self._platform_translations)
config.save(_CONFIG_FILE, self._platform_translations)

action: _Action = ctx.new_action()

Expand All @@ -112,4 +112,4 @@ def _machine_state_changed(
allows for changes made to translations to be re-read in.
"""
if machine_state == STATE_RUNNING:
self._platform_translations = config.load(_CONFIG_FILEPATH)
self._platform_translations = config.load(_CONFIG_FILE)
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]
# NOTE: Although the asyncio module is not used directly in this plugin, it
# seems that some other dependencies do use it. So, this config is added to
# silence the deprecation warnings regarding
# `asyncio_default_fixture_loop_scope`
[pytest]
asyncio_default_fixture_loop_scope = function
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ long_description = file: README.md
long_description_content_type = text/markdown
name = plover_platform_specific_translation
url = https://github.com/paulfioravanti/plover-platform-specific-translation
version = 0.2.4
version = 0.2.5

[options]
install_requires =
Expand All @@ -37,7 +37,7 @@ plover.extension =
plover_platform_specific_translation = plover_platform_specific_translation.extension:PlatformSpecificTranslation

[options.extras_require]
test=
test =
coverage
mypy
pylint
Expand Down

0 comments on commit 8e184e3

Please sign in to comment.