plover-local-env-var


Nameplover-local-env-var JSON
Version 0.2.14 PyPI version JSON
download
home_pagehttps://github.com/paulfioravanti/plover-local-env-var
SummaryUse your local environment variables in Plover
upload_time2024-02-11 00:04:15
maintainer
docs_urlNone
authorPaul Fioravanti
requires_python
licenseGNU General Public License v3 or later (GPLv3+)
keywords plover plover_plugin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Plover Local Env Var

[![Build Status][Build Status image]][Build Status url] [![PyPI - Version][PyPI version image]][PyPI url] [![PyPI - Downloads][PyPI downloads image]][PyPI url] [![linting: pylint][linting image]][linting url]

This [Plover][] [extension][] [plugin][] contains a [meta][] that can read in
and output values stored in local [environment variables][] on your computer.

## Use Case

Ever have information that is not quite secret enough to warrant putting in a
password manager, but not public enough that you want to have steno dictionary
outlines containing it available to the public? Information like your phone
number, home address, and date of birth is very handy to have in outline values
when filling in online forms etc, but I wouldn't want to share that info in
[my steno dictionaries][].

So, in order to be able to share the outlines I use, but not the values
contained in them, I put that kind of semi-secret information in environment
variables, manage them with [direnv][], and use this plugin to access them in
order to write them out.

> [!NOTE]
> If you prefer to manually write out all your semi-secret information and/or
> you do not share your steno dictionaries publicly, you may not need to use
> this plugin at all.

> [!WARNING]
> Please do not put secret information like passwords in your steno dictionary
> outlines! Plover stands between when you write your keystrokes and when they
> output on screen, fitting the very definition of a ["man-in-the-middle"][]
> (see your `strokes.log` file for what Plover records by default). Use a
> password manager.

## Install

1. In the Plover application, open the Plugins Manager (either click the Plugins
   Manager icon, or from the `Tools` menu, select `Plugins Manager`).
2. From the list of plugins, find `plover-local-env-var`
3. Click "Install/Update"
4. When it finishes installing, restart Plover
5. After re-opening Plover, open the Configuration screen (either click the
   Configuration icon, or from the main Plover application menu, select
   `Preferences...`)
6. Open the Plugins tab
7. Check the box next to `plover_local_env_var` to activate the plugin

## How To Use

After defining and [exporting][] environment variables in your [shell
configuration file][], you can use them in your outlines with the `ENV_VAR`
meta. For an environment variable named `$PHONE_NUMBER`, the outline would look
like:

```json
"{:ENV_VAR:$PHONE_NUMBER}"
```

Pressing the "Disconnect and reconnect the machine" button on the Plover UI
resets the environment variable cache. If you make any changes to the values
contained in your environment variables, make sure to press it so they get
re-read in again.

## Why a Plugin?

I used to access environment variables from a steno outline like in this
example:

```json
"PHAEUL/PHAEUL": "{:COMMAND:SHELL:bash -ci 'osascript $STENO_DICTIONARIES/src/command/actions/output-env-var.scpt EMAIL'}"
```

This solution does the following:

- uses the [Plover Run Shell][] plugin to run a shell command from Python
- calls `bash` in [interactive mode][] (`-i`) so that the command can see
  [environment variables][] (`$STENO_DICTIONARIES` in this case) defined outside
  of the Plover environment
- gets `bash` to use the [`osascript`][] command-line tool to load in and run
  the target compiled [AppleScript][] ([`.scpt`][]) file
- The AppleScript in question would then call out to the shell to fetch the
  `$EMAIL` env var, and keystroke it out to the screen

This stack of `Python->Shell->AppleScript->Shell` is convoluted and just not the
right tool for the job at hand. Plover Local Env Var just uses Python and Shell,
and reduces the outline above to be just:

```json
"PHAEUL/PHAEUL": "{:ENV_VAR:$EMAIL}"
```

All the fetched values also get cached, so subsequent calls to the same env var
get returned quicker.

## Development

Clone from GitHub with [git][]:

```console
git clone git@github.com:paulfioravanti/plover-local-env-var.git
cd plover-local-env-var
```

### Python Version

Plover's Python environment currently uses version 3.9 (see Plover's
[`workflow_context.yml`][] to confirm the current version).

So, in order to avoid unexpected issues, use your runtime version manager to
make sure your local development environment also uses Python 3.9.x.

### Testing

- [Pytest][] is used for testing in this plugin.
- [Coverage.py][] and [pytest-cov][] are used for test coverage, and to run
  coverage within Pytest
- [Pylint][] is used for code quality
- [Mypy][] is used for static type checking

Currently, the only parts able to be tested are ones that do not rely directly
on Plover.

Run tests, coverage, and linting with the following commands:

```console
pytest --cov --cov-report=term-missing
pylint plover_local_env_var
mypy plover_local_env_var
```

To get a HTML test coverage report:

```console
coverage run --module pytest
coverage html
open htmlcov/index.html
```

### Deploying Changes

After making any code changes, deploy the plugin into Plover with the following
command:

```console
plover -s plover_plugins install .
```

> Where `plover` in the command is a reference to your locally installed version
> of Plover. See the [Invoke Plover from the command line][] page for details on
> how to create that reference.

[AppleScript]: https://en.wikipedia.org/wiki/AppleScript
[Build Status image]: https://github.com/paulfioravanti/plover-local-env-var/actions/workflows/ci.yml/badge.svg
[Build Status url]: https://github.com/paulfioravanti/plover-local-env-var/actions/workflows/ci.yml
[Coverage.py]: https://github.com/nedbat/coveragepy
[direnv]: https://direnv.net/
[environment variables]: https://en.wikipedia.org/wiki/Environment_variable
[exporting]: https://en.wikipedia.org/wiki/Environment_variable#Assignment:_Unix
[extension]: https://plover.readthedocs.io/en/latest/plugin-dev/extensions.html
[git]: https://git-scm.com/
[interactive mode]: https://www.gnu.org/software/bash/manual/html_node/Interactive-Shell-Behavior.html
[Invoke Plover from the command line]: https://github.com/openstenoproject/plover/wiki/Invoke-Plover-from-the-command-line
[linting image]: https://img.shields.io/badge/linting-pylint-yellowgreen
[linting url]: https://github.com/pylint-dev/pylint
["man-in-the-middle"]: https://en.wikipedia.org/wiki/Man-in-the-middle_attack
[meta]: https://plover.readthedocs.io/en/latest/plugin-dev/metas.html
[my steno dictionaries]: https://github.com/paulfioravanti/steno-dictionaries
[Mypy]: https://github.com/python/mypy
[`osascript`]: https://ss64.com/osx/osascript.html
[Plover]: https://www.openstenoproject.org/
[Plover Run Shell]: https://github.com/user202729/plover_run_shell
[plugin]: https://plover.readthedocs.io/en/latest/plugins.html#types-of-plugins
[Pylint]: https://github.com/pylint-dev/pylint
[PyPI downloads image]:https://img.shields.io/pypi/dm/plover-local-env-var
[PyPI version image]: https://img.shields.io/pypi/v/plover-local-env-var
[PyPI url]: https://pypi.org/project/plover-local-env-var/
[Pytest]: https://pytest.org/
[pytest-cov]: https://github.com/pytest-dev/pytest-cov/
[`.scpt`]: https://fileinfo.com/extension/scpt
[shell configuration file]: https://en.wikipedia.org/wiki/Unix_shell#Configuration_files
[`workflow_context.yml`]: https://github.com/openstenoproject/plover/blob/master/.github/workflows/ci/workflow_context.yml

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/paulfioravanti/plover-local-env-var",
    "name": "plover-local-env-var",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "plover plover_plugin",
    "author": "Paul Fioravanti",
    "author_email": "paul@paulfioravanti.com",
    "download_url": "https://files.pythonhosted.org/packages/60/4c/a637435979c6200a620e6574633ace4a2efacdf56546fb18e50a67b67a36/plover_local_env_var-0.2.14.tar.gz",
    "platform": null,
    "description": "# Plover Local Env Var\n\n[![Build Status][Build Status image]][Build Status url] [![PyPI - Version][PyPI version image]][PyPI url] [![PyPI - Downloads][PyPI downloads image]][PyPI url] [![linting: pylint][linting image]][linting url]\n\nThis [Plover][] [extension][] [plugin][] contains a [meta][] that can read in\nand output values stored in local [environment variables][] on your computer.\n\n## Use Case\n\nEver have information that is not quite secret enough to warrant putting in a\npassword manager, but not public enough that you want to have steno dictionary\noutlines containing it available to the public? Information like your phone\nnumber, home address, and date of birth is very handy to have in outline values\nwhen filling in online forms etc, but I wouldn't want to share that info in\n[my steno dictionaries][].\n\nSo, in order to be able to share the outlines I use, but not the values\ncontained in them, I put that kind of semi-secret information in environment\nvariables, manage them with [direnv][], and use this plugin to access them in\norder to write them out.\n\n> [!NOTE]\n> If you prefer to manually write out all your semi-secret information and/or\n> you do not share your steno dictionaries publicly, you may not need to use\n> this plugin at all.\n\n> [!WARNING]\n> Please do not put secret information like passwords in your steno dictionary\n> outlines! Plover stands between when you write your keystrokes and when they\n> output on screen, fitting the very definition of a [\"man-in-the-middle\"][]\n> (see your `strokes.log` file for what Plover records by default). Use a\n> password manager.\n\n## Install\n\n1. In the Plover application, open the Plugins Manager (either click the Plugins\n   Manager icon, or from the `Tools` menu, select `Plugins Manager`).\n2. From the list of plugins, find `plover-local-env-var`\n3. Click \"Install/Update\"\n4. When it finishes installing, restart Plover\n5. After re-opening Plover, open the Configuration screen (either click the\n   Configuration icon, or from the main Plover application menu, select\n   `Preferences...`)\n6. Open the Plugins tab\n7. Check the box next to `plover_local_env_var` to activate the plugin\n\n## How To Use\n\nAfter defining and [exporting][] environment variables in your [shell\nconfiguration file][], you can use them in your outlines with the `ENV_VAR`\nmeta. For an environment variable named `$PHONE_NUMBER`, the outline would look\nlike:\n\n```json\n\"{:ENV_VAR:$PHONE_NUMBER}\"\n```\n\nPressing the \"Disconnect and reconnect the machine\" button on the Plover UI\nresets the environment variable cache. If you make any changes to the values\ncontained in your environment variables, make sure to press it so they get\nre-read in again.\n\n## Why a Plugin?\n\nI used to access environment variables from a steno outline like in this\nexample:\n\n```json\n\"PHAEUL/PHAEUL\": \"{:COMMAND:SHELL:bash -ci 'osascript $STENO_DICTIONARIES/src/command/actions/output-env-var.scpt EMAIL'}\"\n```\n\nThis solution does the following:\n\n- uses the [Plover Run Shell][] plugin to run a shell command from Python\n- calls `bash` in [interactive mode][] (`-i`) so that the command can see\n  [environment variables][] (`$STENO_DICTIONARIES` in this case) defined outside\n  of the Plover environment\n- gets `bash` to use the [`osascript`][] command-line tool to load in and run\n  the target compiled [AppleScript][] ([`.scpt`][]) file\n- The AppleScript in question would then call out to the shell to fetch the\n  `$EMAIL` env var, and keystroke it out to the screen\n\nThis stack of `Python->Shell->AppleScript->Shell` is convoluted and just not the\nright tool for the job at hand. Plover Local Env Var just uses Python and Shell,\nand reduces the outline above to be just:\n\n```json\n\"PHAEUL/PHAEUL\": \"{:ENV_VAR:$EMAIL}\"\n```\n\nAll the fetched values also get cached, so subsequent calls to the same env var\nget returned quicker.\n\n## Development\n\nClone from GitHub with [git][]:\n\n```console\ngit clone git@github.com:paulfioravanti/plover-local-env-var.git\ncd plover-local-env-var\n```\n\n### Python Version\n\nPlover's Python environment currently uses version 3.9 (see Plover's\n[`workflow_context.yml`][] to confirm the current version).\n\nSo, in order to avoid unexpected issues, use your runtime version manager to\nmake sure your local development environment also uses Python 3.9.x.\n\n### Testing\n\n- [Pytest][] is used for testing in this plugin.\n- [Coverage.py][] and [pytest-cov][] are used for test coverage, and to run\n  coverage within Pytest\n- [Pylint][] is used for code quality\n- [Mypy][] is used for static type checking\n\nCurrently, the only parts able to be tested are ones that do not rely directly\non Plover.\n\nRun tests, coverage, and linting with the following commands:\n\n```console\npytest --cov --cov-report=term-missing\npylint plover_local_env_var\nmypy plover_local_env_var\n```\n\nTo get a HTML test coverage report:\n\n```console\ncoverage run --module pytest\ncoverage html\nopen htmlcov/index.html\n```\n\n### Deploying Changes\n\nAfter making any code changes, deploy the plugin into Plover with the following\ncommand:\n\n```console\nplover -s plover_plugins install .\n```\n\n> Where `plover` in the command is a reference to your locally installed version\n> of Plover. See the [Invoke Plover from the command line][] page for details on\n> how to create that reference.\n\n[AppleScript]: https://en.wikipedia.org/wiki/AppleScript\n[Build Status image]: https://github.com/paulfioravanti/plover-local-env-var/actions/workflows/ci.yml/badge.svg\n[Build Status url]: https://github.com/paulfioravanti/plover-local-env-var/actions/workflows/ci.yml\n[Coverage.py]: https://github.com/nedbat/coveragepy\n[direnv]: https://direnv.net/\n[environment variables]: https://en.wikipedia.org/wiki/Environment_variable\n[exporting]: https://en.wikipedia.org/wiki/Environment_variable#Assignment:_Unix\n[extension]: https://plover.readthedocs.io/en/latest/plugin-dev/extensions.html\n[git]: https://git-scm.com/\n[interactive mode]: https://www.gnu.org/software/bash/manual/html_node/Interactive-Shell-Behavior.html\n[Invoke Plover from the command line]: https://github.com/openstenoproject/plover/wiki/Invoke-Plover-from-the-command-line\n[linting image]: https://img.shields.io/badge/linting-pylint-yellowgreen\n[linting url]: https://github.com/pylint-dev/pylint\n[\"man-in-the-middle\"]: https://en.wikipedia.org/wiki/Man-in-the-middle_attack\n[meta]: https://plover.readthedocs.io/en/latest/plugin-dev/metas.html\n[my steno dictionaries]: https://github.com/paulfioravanti/steno-dictionaries\n[Mypy]: https://github.com/python/mypy\n[`osascript`]: https://ss64.com/osx/osascript.html\n[Plover]: https://www.openstenoproject.org/\n[Plover Run Shell]: https://github.com/user202729/plover_run_shell\n[plugin]: https://plover.readthedocs.io/en/latest/plugins.html#types-of-plugins\n[Pylint]: https://github.com/pylint-dev/pylint\n[PyPI downloads image]:https://img.shields.io/pypi/dm/plover-local-env-var\n[PyPI version image]: https://img.shields.io/pypi/v/plover-local-env-var\n[PyPI url]: https://pypi.org/project/plover-local-env-var/\n[Pytest]: https://pytest.org/\n[pytest-cov]: https://github.com/pytest-dev/pytest-cov/\n[`.scpt`]: https://fileinfo.com/extension/scpt\n[shell configuration file]: https://en.wikipedia.org/wiki/Unix_shell#Configuration_files\n[`workflow_context.yml`]: https://github.com/openstenoproject/plover/blob/master/.github/workflows/ci/workflow_context.yml\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 or later (GPLv3+)",
    "summary": "Use your local environment variables in Plover",
    "version": "0.2.14",
    "project_urls": {
        "Homepage": "https://github.com/paulfioravanti/plover-local-env-var"
    },
    "split_keywords": [
        "plover",
        "plover_plugin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "947655b97c85228a0474598795f361613aa84feef5b22ee797774d3b25b2a8bc",
                "md5": "044c2d58de1fd4e369706dce571a634d",
                "sha256": "37065b4a4e752c5dcf81cf213a768fc19cfd77d7da2e658d2d30a139e85cc973"
            },
            "downloads": -1,
            "filename": "plover_local_env_var-0.2.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "044c2d58de1fd4e369706dce571a634d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 21354,
            "upload_time": "2024-02-11T00:04:14",
            "upload_time_iso_8601": "2024-02-11T00:04:14.507529Z",
            "url": "https://files.pythonhosted.org/packages/94/76/55b97c85228a0474598795f361613aa84feef5b22ee797774d3b25b2a8bc/plover_local_env_var-0.2.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "604ca637435979c6200a620e6574633ace4a2efacdf56546fb18e50a67b67a36",
                "md5": "269a5d411c9f195513f382e8f7b0bc63",
                "sha256": "549f8926d095c563e460326da1a922f1cff7df49441426676c8b6c118190db35"
            },
            "downloads": -1,
            "filename": "plover_local_env_var-0.2.14.tar.gz",
            "has_sig": false,
            "md5_digest": "269a5d411c9f195513f382e8f7b0bc63",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22079,
            "upload_time": "2024-02-11T00:04:15",
            "upload_time_iso_8601": "2024-02-11T00:04:15.671214Z",
            "url": "https://files.pythonhosted.org/packages/60/4c/a637435979c6200a620e6574633ace4a2efacdf56546fb18e50a67b67a36/plover_local_env_var-0.2.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-11 00:04:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "paulfioravanti",
    "github_project": "plover-local-env-var",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "plover-local-env-var"
}
        
Elapsed time: 0.19100s