19 lines
768 B
Python
19 lines
768 B
Python
"""Bundled resources and writable, private user data locations."""
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def resource_root() -> Path:
|
|
source = Path(__file__).resolve().parent.parent
|
|
return source if (source / 'templates/invoice.html.j2').is_file() else Path(__file__).resolve().parent / 'data'
|
|
|
|
|
|
def private_root(resources: Path | None = None) -> Path:
|
|
root = resources or resource_root()
|
|
default = root / 'private' if root.name != 'data' else Path.home() / '.local/share/jr-einvoice'
|
|
return Path(os.environ.get('JR_EINVOICE_HOME', str(default))).expanduser().resolve()
|
|
|
|
|
|
def presets_root(resources: Path | None = None) -> Path:
|
|
return Path(os.environ.get('JR_EINVOICE_PRESETS', str(private_root(resources) / 'presets'))).expanduser().resolve()
|