feat: move new_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
75d623a124
commit
3d053d532a
12 changed files with 239 additions and 105 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue