openeditor
Edit files with your $EDITOR, like git commit does.
Usage
Install with: pip install openeditor
# Let user edit file
s = openeditor.edit_file("path/to/my/file.txt")
print("The file now contains:\n" + s)
# Use a temp file
s = openeditor.edit_file(
"# Please edit this file, save and close editor when done",
"path/to/my/file.txt"
)
print("The file now contains:\n" + s)
The editor is obtained from, in order of precedence:
$VISUAL$EDITOR
If neither of these provide a useful editor, an exception will be thrown.
Limitations
openeditor expects an editor string similar to EDITOR=cmd such that:
cmd file.txt(filename as the final argument) is a correct way of editingfile.txt.cmdis not too complex. Simple things like space-separated flags (eg.EDITOR="vim -n") are fine but advanced shell magic may break.
If your cmd does need to be more complex, one possible workaround is to write a wrapper script that presents a compatible command-line interface to openeditor and invokes the full command as appopriate.
Release files for openeditor 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openeditor-0.3.1.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openeditor-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / openeditor-0.3.1.tar.gz
| Download URL | openeditor-0.3.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
415d2f847b12a112f8d16989c37a697c93fd3b60f4cbf27d180f7815f08c132a
|
|
BLAKE2b-256 checksum How to use checksums |
462c36fe02e5f3a64849dd1a638921bc86fedfc6a4b59b39b180a9ba331ef6a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.3 Linux/5.10.30-1-MANJARO
|
Release files / openeditor-0.3.1-py3-none-any.whl
| Download URL | openeditor-0.3.1-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
251c792a10fe67bdd6b8b31b9ba4264a349f38740ddad0a5a47223c8bc85d26b
|
|
BLAKE2b-256 checksum How to use checksums |
ebb6b3cf4bcbe8b416872736da91da224203c65e93ad452c41a387a1524c4e16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.3 Linux/5.10.30-1-MANJARO
|