Skip to content

Commit 749dae4

Browse files
committed
improved file type handling for edge cases and bumping to v3.6.0
1 parent 570486b commit 749dae4

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/codemapper/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
creating detailed Markdown documentation of their structure and contents.
77
"""
88

9-
__version__ = "3.5.3"
9+
__version__ = "3.6.0"
1010

1111
# Any other necessary imports or package-level code can go here

src/codemapper/codemapper.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,28 @@ def is_large_file(file_path: str) -> bool:
385385
bool: True if the file is considered large or binary, False otherwise.
386386
"""
387387
_, ext = os.path.splitext(file_path.lower())
388+
file_name = os.path.basename(file_path)
389+
390+
# Check if it's in LARGE_FILE_EXTENSIONS
388391
if ext in LARGE_FILE_EXTENSIONS:
389392
return True
390393

394+
# Check if it's in CODE_FENCE_MAP
395+
if ext in CODE_FENCE_MAP or file_name in CODE_FENCE_MAP:
396+
return False
397+
398+
# Fallback to MIME type check
391399
mime_type, _ = mimetypes.guess_type(file_path)
392-
return bool(mime_type) and not mime_type.startswith("text")
400+
if mime_type:
401+
# List of MIME types that are considered text-based
402+
text_mime_types = [
403+
"text/", "application/json", "application/javascript", "application/xml",
404+
"application/x-httpd-php", "application/x-sh", "application/x-csh"
405+
]
406+
return not any(mime_type.startswith(text_type) for text_type in text_mime_types)
407+
408+
# If MIME type couldn't be determined, assume it's not a large file
409+
return False
393410

394411

395412
def get_file_info(file_path: str) -> str:

0 commit comments

Comments
 (0)