Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
fix: --export-template correctly exports all notes
Browse files Browse the repository at this point in the history
  • Loading branch information
natelandau committed Mar 22, 2023
1 parent 98fa996 commit 4bf1acb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/obsidian_metadata/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def main(
raise typer.Exit(code=0)
if export_template is not None:
path = Path(export_template).expanduser().resolve()
application.noninteractive_export_csv(path)
application.noninteractive_export_template(path)
raise typer.Exit(code=0)

application.application_main()
Expand Down
10 changes: 10 additions & 0 deletions src/obsidian_metadata/models/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,16 @@ def noninteractive_export_json(self, path: Path) -> None:
self.vault.export_metadata(export_format="json", path=str(path))
alerts.success(f"Exported metadata to {path}")

def noninteractive_export_template(self, path: Path) -> None:
"""Export the vault metadata to CSV."""
self._load_vault()
with console.status(
"Preparing export... [dim](Can take a while for large vaults)[/]",
spinner="bouncingBall",
):
self.vault.export_notes_to_csv(path=str(path))
alerts.success(f"Exported metadata to {path}")

def rename_key(self) -> None:
"""Rename a key in the vault."""
original_key = self.questions.ask_existing_key(
Expand Down
21 changes: 8 additions & 13 deletions src/obsidian_metadata/models/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import rich.repr
import typer
from rich import box
from rich.progress import Progress, SpinnerColumn, TextColumn
from rich.prompt import Confirm
from rich.table import Table

Expand Down Expand Up @@ -64,12 +63,10 @@ def __init__(
self.filters = filters
self.all_note_paths = self._find_markdown_notes()

with Progress(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
transient=True,
) as progress:
progress.add_task(description="Processing notes...", total=None)
with console.status(
"Processing notes... [dim](Can take a while for a large vault)[/]",
spinner="bouncingBall",
):
self.all_notes: list[Note] = [
Note(note_path=p, dry_run=self.dry_run) for p in self.all_note_paths
]
Expand Down Expand Up @@ -172,12 +169,10 @@ def _find_markdown_notes(self) -> list[Path]:
def _rebuild_vault_metadata(self) -> None:
"""Rebuild vault metadata."""
self.metadata = VaultMetadata()
with Progress(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
transient=True,
) as progress:
progress.add_task(description="Processing notes...", total=None)
with console.status(
"Processing notes... [dim](Can take a while for a large vault)[/]",
spinner="bouncingBall",
):
for _note in self.notes_in_scope:
self.metadata.index_metadata(
area=MetadataType.FRONTMATTER, metadata=_note.frontmatter.dict
Expand Down

0 comments on commit 4bf1acb

Please sign in to comment.