feat: move new_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 15:35:37 +02:00
commit 3d053d532a
Signed by: catalin
GPG key ID: 0178DF42F43E5FD2
12 changed files with 239 additions and 105 deletions

View file

@ -19,16 +19,32 @@ def resolve_path(path: Path) -> Path:
return path
def wait_for_editor(path):
def get_template_data(path: Path) -> str | None:
"""Read template data from path/template.halig
Args:
path(Path): The path to read template data from, usually a notebook
Returns:
maybe returns a string containing the template data
"""
template_path = path / "template.halig"
if not (template_path.exists() and template_path.is_file()):
return None
with open(template_path) as f:
return f.read()
def wait_for_editor(filepath: str):
"""Wait for $EDITOR to be opened and then manually closed by the user
Args:
path(Path): The filepath which $EDITOR should modify
filepath(Path): The filepath which $EDITOR should modify
Raises:
CouldNotEditTempfile if the subprocess call errors out
"""
try:
subprocess.call([os.environ.get("EDITOR", "vim"), path])
subprocess.call([os.environ.get("EDITOR", "vim"), filepath])
except subprocess.CalledProcessError as e:
logger.error(e.output)
raise CouldNotEditTempfile