Skip to content

Commit 05966c6

Browse files
enh: add debug prints to the filetype detector
Signed-off-by: thiswillbeyourgithub <[email protected]>
1 parent 520f4ce commit 05966c6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

wdoc/utils/batch_file_loader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def infer_filetype(path: str) -> str:
100100
for k, v in inference_rules.items():
101101
for vv in inference_rules[k]:
102102
if vv.search(path):
103+
logger.debug(f"Regex infered that path '{path}' is of filetype '{k}'")
103104
return k
104105
fp = Path(path)
105106
if not fp.exists():
@@ -121,10 +122,13 @@ def infer_filetype(path: str) -> str:
121122
f"Failed to detect 'auto' filetype for '{fp}' with regex and even python-magic. Error: '{err}'"
122123
) from err
123124
if "pdf" in info:
125+
logger.debug(f"Magic infered that path '{path}' is of filetype 'pdf'")
124126
return "pdf"
125127
elif "mpeg" in info or "mp3" in info:
128+
logger.debug(f"Magic infered that path '{path}' is of filetype 'local_audio'")
126129
return "local_audio"
127130
elif "epub" in info:
131+
logger.debug(f"Magic infered that path '{path}' is of filetype 'epub'")
128132
return "epub"
129133
else:
130134
raise NoInferrableFiletype(

0 commit comments

Comments
 (0)