Skip to content

Commit 1f71cd7

Browse files
Refactor main.py: Improve text MIME type checking logic; remove redundant imports and enhance readability
1 parent 74c8ca9 commit 1f71cd7

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

extliner/main.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import os
22
import json
3+
import mimetypes
4+
from tqdm import tqdm
35
from pathlib import Path
46
from collections import defaultdict
57
from typing import Dict, List, Optional, Tuple, Union
68
from concurrent.futures import ProcessPoolExecutor, as_completed
79

8-
from tqdm import tqdm
9-
10-
11-
import mimetypes
12-
1310
def is_text_mimetype(path: str) -> bool:
1411
mime, _ = mimetypes.guess_type(path)
15-
return mime is not None and mime.startswith("text/")
12+
return mime is not None and (mime.startswith("text/") or mime == "application/json")
1613

1714
def process_file(filepath: str, encoding: str) -> Optional[Tuple[str, int, int]]:
1815
ext = (Path(filepath).suffix or "NO_EXT").lower()
@@ -38,7 +35,7 @@ def _recursive_scan(path: Path):
3835
elif entry.is_file(follow_symlinks=False):
3936
ext = entry_path.suffix.lower() or "NO_EXT"
4037
if ext not in ignore_exts:
41-
if is_text_mimetype(entry_path):
38+
if is_text_mimetype(entry_path): # type: ignore
4239
file_list.append(str(entry_path))
4340

4441
_recursive_scan(directory)

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def load_requirements(file_path):
4747
"Programming Language :: Python :: 3",
4848
"Operating System :: OS Independent",
4949
"Intended Audience :: Developers",
50-
"License :: OSI Approved :: MIT License"
5150
],
5251
project_urls={
5352
"Documentation": DOCS_URL,

0 commit comments

Comments
 (0)