Skip to content

Commit

Permalink
Add clickable links to file names in the printed report (#100)
Browse files Browse the repository at this point in the history
Co-authored-by: I-Al-Istannen <i-al-istannen@users.noreply.github.com>
  • Loading branch information
Scriptim and I-Al-Istannen authored Nov 3, 2024
1 parent f5c4e82 commit 26e802d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ambiguous situations.

### Added
- Support for MOB videos in page descriptions
- Clickable links in the report to directly open new/modified/not-deleted files

### Changed
- Remove videos from description pages
Expand Down
4 changes: 4 additions & 0 deletions PFERD/crawl/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ def report(self) -> Report:
def prev_report(self) -> Optional[Report]:
return self._output_dir.prev_report

@property
def output_dir(self) -> OutputDirectory:
return self._output_dir

@staticmethod
async def gather(awaitables: Sequence[Awaitable[Any]]) -> List[Any]:
"""
Expand Down
14 changes: 10 additions & 4 deletions PFERD/pferd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
from pathlib import Path, PurePath
from typing import Dict, List, Optional
from urllib.parse import quote

from rich.markup import escape

Expand Down Expand Up @@ -168,19 +169,24 @@ def print_report(self) -> None:
log.report("")
log.report(f"[bold bright_cyan]Report[/] for {escape(name)}")

def fmt_path_link(relative_path: PurePath) -> str:
# We need to URL-encode the path because it might contain spaces or special characters
link = f"file://{quote(str(crawler.output_dir.resolve(relative_path).absolute()))}"
return f"[link={link}]{fmt_path(relative_path)}[/link]"

something_changed = False
for path in sorted(crawler.report.added_files):
something_changed = True
log.report(f" [bold bright_green]Added[/] {fmt_path(path)}")
log.report(f" [bold bright_green]Added[/] {fmt_path_link(path)}")
for path in sorted(crawler.report.changed_files):
something_changed = True
log.report(f" [bold bright_yellow]Changed[/] {fmt_path(path)}")
log.report(f" [bold bright_yellow]Changed[/] {fmt_path_link(path)}")
for path in sorted(crawler.report.deleted_files):
something_changed = True
log.report(f" [bold bright_magenta]Deleted[/] {fmt_path(path)}")
for path in sorted(crawler.report.not_deleted_files):
something_changed = True
log.report_not_deleted(f" [bold bright_magenta]Not deleted[/] {fmt_path(path)}")
log.report_not_deleted(f" [bold bright_magenta]Not deleted[/] {fmt_path_link(path)}")

for warning in crawler.report.encountered_warnings:
something_changed = True
Expand Down

0 comments on commit 26e802d

Please sign in to comment.