Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up leftover template files #1088

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions betty/fs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import asyncio
import hashlib
import os
from collections import deque
Expand All @@ -12,7 +13,6 @@

import aiofiles
from aiofiles.os import makedirs
from aiofiles.ospath import exists
from aiofiles.threadpool.text import AsyncTextIOWrapper

from betty import _ROOT_DIRECTORY_PATH
Expand Down Expand Up @@ -86,13 +86,12 @@ async def copy2(self, source_path: Path, destination_path: Path) -> Path:
raise FileNotFoundError('Could not find any of %s.' % ', '.join(tried_paths))

async def copytree(self, source_path: Path, destination_path: Path) -> AsyncIterable[Path]:
destination_paths = set()
file_destination_paths = set()
for fs_path, _ in self._paths:
async for file_source_path in iterfiles(fs_path / source_path):
file_destination_path = destination_path / file_source_path.relative_to(fs_path / source_path)
if not await exists(file_destination_path):
if file_destination_path not in file_destination_paths:
file_destination_paths.add(file_destination_path)
await makedirs(file_destination_path.parent, exist_ok=True)
copy2(file_source_path, file_destination_path)
if file_destination_path not in destination_paths:
destination_paths.add(file_destination_path)
yield file_destination_path
await asyncio.to_thread(copy2, file_source_path, file_destination_path)
yield file_destination_path
2 changes: 1 addition & 1 deletion betty/tests/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async def test_source(self) -> None:
class TestResourceOverride:
async def test(self) -> None:
async with App() as app:
localized_assets_directory_path = Path(app.project.configuration.assets_directory_path) / 'public' / 'static'
localized_assets_directory_path = Path(app.project.configuration.assets_directory_path) / 'public' / 'localized'
localized_assets_directory_path.mkdir(parents=True)
with open(str(localized_assets_directory_path / 'index.html.j2'), 'w') as f:
f.write('{% block page_content %}Betty was here{% endblock %}')
Expand Down