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

bugfix/fix missing extensions in file detection #3926

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.16.22-dev0

### Fixes

* **Handle filenames without extensions in file type detection**

## 0.16.21

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion unstructured/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.16.21" # pragma: no cover
__version__ = "0.16.22-dev0" # pragma: no cover
8 changes: 6 additions & 2 deletions unstructured/file_utils/filetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,15 @@ def extension(self) -> str:
# -- get from file_path, or file when it has a name (path) --
with self.open() as file:
if hasattr(file, "name") and file.name:
return os.path.splitext(file.name)[1].lower()
splitext = os.path.splitext(file.name)
if len(splitext) > 1:
return splitext[1].lower()

# -- otherwise use metadata file-path when provided --
if file_path := self._metadata_file_path:
return os.path.splitext(file_path)[1].lower()
splitext = os.path.splitext(file_path)
if len(splitext) > 1:
return splitext[1].lower()

# -- otherwise empty str means no extension, same as a path like "a/b/name-no-ext" --
return ""
Expand Down
Loading