Skip to content

Commit

Permalink
Clean up leftover template files. (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra authored Dec 22, 2023
1 parent 833d9d2 commit d0b3d12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
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

0 comments on commit d0b3d12

Please sign in to comment.