feat: move edit_note function to a separate file
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
c25156fe4c
commit
75d623a124
10 changed files with 191 additions and 42 deletions
34
halig/utils.py
Normal file
34
halig/utils.py
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue