Extract text editor utils
This commit is contained in:
parent
58e8b10553
commit
25100ef39d
|
@ -85,22 +85,8 @@ from utils.download import run_lxc_download_script
|
|||
from utils.files import stat_chmod
|
||||
from utils.jail_dataset import get_zfs_dataset, create_zfs_dataset, remove_zfs_dataset
|
||||
|
||||
|
||||
def get_text_editor():
|
||||
def get_from_environ(key):
|
||||
if editor := os.environ.get(key):
|
||||
return shutil.which(editor)
|
||||
|
||||
return (
|
||||
get_from_environ("VISUAL")
|
||||
or get_from_environ("EDITOR")
|
||||
or shutil.which("editor")
|
||||
or shutil.which("/usr/bin/editor")
|
||||
or "nano"
|
||||
)
|
||||
|
||||
|
||||
from actions.create import create_jail
|
||||
from utils.editor import get_text_editor
|
||||
from utils.jail_dataset import jail_is_running
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers <https://github.com/Jip-Hop/jailmaker>
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
def get_text_editor():
|
||||
def get_from_environ(key):
|
||||
if editor := os.environ.get(key):
|
||||
return shutil.which(editor)
|
||||
|
||||
return (
|
||||
get_from_environ("VISUAL")
|
||||
or get_from_environ("EDITOR")
|
||||
or shutil.which("editor")
|
||||
or shutil.which("/usr/bin/editor")
|
||||
or "nano"
|
||||
)
|
Loading…
Reference in New Issue