Skip to content

Commit 6a1a154

Browse files
committed
fix: restore _is_binary_file function for test compatibility
1 parent f1cf609 commit 6a1a154

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/treemapper/tree.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ def _create_node(entry: Path, ctx: TreeBuildContext, current_depth: int) -> Opti
8888
return None
8989

9090

91+
def _is_binary_file(file_path: Path, sample_size: int = BINARY_DETECTION_SAMPLE_SIZE) -> bool:
92+
try:
93+
with file_path.open("rb") as f:
94+
return b"\x00" in f.read(sample_size)
95+
except OSError:
96+
return False
97+
98+
9199
def _read_file_content(file_path: Path, max_file_bytes: Optional[int]) -> str:
92100
try:
93101
file_size = file_path.stat().st_size

0 commit comments

Comments
 (0)