{"id":15164655,"url":"https://github.com/user202729/plover-python-dictionary-cmd","last_synced_at":"2026-02-14T05:07:24.500Z","repository":{"id":232743852,"uuid":"785101077","full_name":"user202729/plover-python-dictionary-cmd","owner":"user202729","description":"Execute arbitrary command from a Python dictionary.","archived":false,"fork":false,"pushed_at":"2025-03-08T09:21:35.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-29T00:59:38.103Z","etag":null,"topics":["plover","plover-plugins","stenography"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/user202729.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-11T07:43:01.000Z","updated_at":"2025-03-08T09:21:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a5562d0-b9cc-414f-baaf-858244cd2175","html_url":"https://github.com/user202729/plover-python-dictionary-cmd","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"10f3b84b6ecee891bdf96d4f3fc220f05db3d1bd"},"previous_names":["user202729/plover-python-dictionary-cmd"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/user202729/plover-python-dictionary-cmd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user202729%2Fplover-python-dictionary-cmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user202729%2Fplover-python-dictionary-cmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user202729%2Fplover-python-dictionary-cmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user202729%2Fplover-python-dictionary-cmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/user202729","download_url":"https://codeload.github.com/user202729/plover-python-dictionary-cmd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/user202729%2Fplover-python-dictionary-cmd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29437368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T03:34:37.767Z","status":"ssl_error","status_checked_at":"2026-02-14T03:34:09.092Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plover","plover-plugins","stenography"],"created_at":"2024-09-27T03:42:36.101Z","updated_at":"2026-02-14T05:07:24.488Z","avatar_url":"https://github.com/user202729.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# plover-python-dictionary-cmd\n\n[![PyPI](https://img.shields.io/pypi/v/plover-python-dictionary-cmd?style=flat)](https://pypi.python.org/pypi/plover-python-dictionary-cmd/)\n\nExecute arbitrary command from a Python dictionary.\n\n**Warning**: While this plugin can do everything what a command plugin can, this should\nonly be used for personal usage. If the usage is sufficiently general, it's recommended to make\na Plover command plugin instead.\n\nSee also: [`plover-run-shell`](https://github.com/user202729/plover_run_shell), [`plover-run-py`](https://github.com/user202729/plover-run-py), [`plover-open-url`](https://github.com/user202729/plover-comment).\n\n## What problem does this plugin solve?\n\nFirst, this assumes you know what a [Python dictionary](https://github.com/openstenoproject/plover_python_dictionary) is.\n\nMaybe you want to write a dictionary that looks like this:\n\n```python\nLONGEST_KEY = 1\n\ndef lookup(key):\n    if key == (\"SKWR-F\",):\n        return \"{PLOVER:OPEN_URL:https://www.openstenoproject.org/}\"\n```\n\nThe `{PLOVER:OPEN_URL:…}` obviously opens the said URL, using [Plover Open URL plugin](https://github.com/nsmarkop/plover_open_url).\n\nProblem: what if the task you want to do is not already covered by some command plugin?\n\nWhile you can certainly write a new command plugin, that is rather time-consuming.\n\nThe following **will not work**:\n\n```python\nimport webbrowser\n\nLONGEST_KEY = 1\n\ndef lookup(key):\n    if key == (\"SKWR-F\",):\n        webbrowser.open(\"https://www.openstenoproject.org/\")\n```\nIt's because the dictionary may be looked up **multiple times**.\n\n## The solution\n\nWrite the plugin like the following.\n\n```python\nimport webbrowser\nimport plover_python_dictionary_cmd\n\nLONGEST_KEY = 1\n\n@plover_python_dictionary_cmd.register\ndef f(engine):\n    webbrowser.open(\"https://www.openstenoproject.org/\")\n\ndef lookup(key):\n    if key == (\"SKWR-F\",):\n        return str(f)  # or: f.str_with_args()\n```\n\nAs an extra bonus, you get access to the `engine` object inside the function `f` above.\n\n## Extra\n\n`f.str_with_args()` works as follows:\n`f.str_with_args(1, 2)` returns a string, which when interpreted as a Plover command\nand executed, will call `f(engine, 1, 2)`.\n\nAs such, you can also modify the code above as follows:\n\n```python\n@plover_python_dictionary_cmd.register\ndef f(engine, url):\n    webbrowser.open(url)\n\ndef lookup(key):\n    if key == (\"SKWR-F\",):\n        return f.str_with_args(\"https://www.openstenoproject.org/\")\n```\n\n## Internal implementation detail\n\nIt uses a global lookup table to store the reference to the function `f`. Then `str(f)` as above\nreturns something like `{plover:python_dictionary_cmd:123456}` where `123456` is some unique ID.\n\nDon't rely on this implementation detail.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuser202729%2Fplover-python-dictionary-cmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuser202729%2Fplover-python-dictionary-cmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuser202729%2Fplover-python-dictionary-cmd/lists"}