This commit is contained in:
Kovid Goyal 2021-07-16 21:40:14 +05:30
commit a9630890fd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -28,6 +28,8 @@ def is_rc_file(path: str) -> bool:
name = os.path.basename(path) name = os.path.basename(path)
return '.' not in name and name.endswith('rc') return '.' not in name and name.endswith('rc')
def is_folder(path: str) -> bool:
return os.path.isdir(path)
def initialize_mime_database() -> None: def initialize_mime_database() -> None:
if hasattr(initialize_mime_database, 'inited'): if hasattr(initialize_mime_database, 'inited'):
@ -54,4 +56,6 @@ def guess_type(path: str) -> Optional[str]:
mt = 'text/' + mt.split('/', 1)[-1] mt = 'text/' + mt.split('/', 1)[-1]
if not mt and is_rc_file(path): if not mt and is_rc_file(path):
mt = 'text/plain' mt = 'text/plain'
if not mt and is_folder(path):
mt = 'inode/directory'
return mt return mt