Skip to content

Commit

Permalink
Use io from antsibull-fileutils.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Sep 9, 2024
1 parent 13266c2 commit 7c59d50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/antsibull_docs/extra_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import asyncio_pool # type: ignore[import]
from antsibull_core import app_context
from antsibull_core.logging import log
from antsibull_core.utils.io import read_file
from antsibull_fileutils.io import read_file
from antsibull_fileutils.yaml import load_yaml_file

mlog = log.fields(mod=__name__)
Expand Down
17 changes: 13 additions & 4 deletions src/antsibull_docs/write_docs/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
from collections import defaultdict
from threading import Lock

from antsibull_core import app_context
from antsibull_core.logging import log
from antsibull_core.utils.io import copy_file as _copy_file
from antsibull_core.utils.io import write_file as _write_file
from antsibull_fileutils.io import copy_file as _copy_file
from antsibull_fileutils.io import write_file as _write_file

if t.TYPE_CHECKING:
from _typeshed import StrOrBytesPath
Expand Down Expand Up @@ -51,7 +52,8 @@ async def write_file(self, filename: StrOrBytesPath, /, content: str) -> None:
Write the given text content to a file (relative to our root).
"""
path = os.path.join(self.root, filename) # type: ignore
await _write_file(path, content)
lib_ctx = app_context.lib_ctx.get()
await _write_file(path, content, file_check_content=lib_ctx.file_check_content)

async def copy_file(
self,
Expand All @@ -66,7 +68,14 @@ async def copy_file(
(relative to our root).
"""
src_path = os.path.join(self.root, dest_path) # type: ignore
await _copy_file(source_path, src_path, check_content=check_content)
lib_ctx = app_context.lib_ctx.get()
await _copy_file(
source_path,
src_path,
check_content=check_content,
file_check_content=lib_ctx.file_check_content,
chunksize=lib_ctx.chunksize,
)


class TrackingOutput(Output):
Expand Down

0 comments on commit 7c59d50

Please sign in to comment.