feat: move edit_note function to a separate file
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
cătălin 2022-08-28 12:12:31 +02:00
commit 75d623a124
Signed by: catalin
GPG key ID: 0178DF42F43E5FD2
10 changed files with 191 additions and 42 deletions

34
halig/utils.py Normal file
View file

@ -0,0 +1,34 @@
import os
import subprocess
from pathlib import Path
from halig import logger
from halig.exceptions import CouldNotEditTempfile
def resolve_path(path: Path) -> Path:
"""Resolve a path's relative attributes, like envvars, relative notations, etc
Args:
path(Path): The path to resolve
Returns:
Path: The resolved path
"""
path = Path("~/.config/halig/halig.yml").expanduser()
return path
def wait_for_editor(path):
"""Wait for $EDITOR to be opened and then manually closed by the user
Args:
path(Path): The filepath which $EDITOR should modify
Raises:
CouldNotEditTempfile if the subprocess call errors out
"""
try:
subprocess.call([os.environ.get("EDITOR", "vim"), path])
except subprocess.CalledProcessError as e:
logger.error(e.output)
raise CouldNotEditTempfile