File size: 417 Bytes
e5b884f
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import os
class DocumentOperation:
    @staticmethod
    def get_file_type_by_extension(filename):
        _, extension = os.path.splitext(filename)
        extension = extension.lower()
        if extension == ".txt":
            return "text"
        elif extension == ".pdf":
            return "pdf"
        elif extension in [".doc", ".docx"]:
            return "word"
        else:
            return "unknown"