]> git.parisson.com Git - telecaster-client.git/commitdiff
avoid mimetype
authorGuillaume Pellerin <guillaume.pellerin@free.fr>
Mon, 5 Feb 2024 14:38:49 +0000 (15:38 +0100)
committerGuillaume Pellerin <guillaume.pellerin@free.fr>
Mon, 5 Feb 2024 14:38:49 +0000 (15:38 +0100)
telecaster/tools/tools.py

index aa7a74a0c88d664fc97ab22bc3918b4e12489308..f4a1ed9a9a8518dae4790b2e39aa0ea86d4f6784 100644 (file)
@@ -164,15 +164,15 @@ def norm_string(string):
 
 
 def get_conf_dict(file):
-    mime_type = mimetypes.guess_type(file)[0]
+    filename, ext = os.path.splitext(file)
 
     # Do the type check first, so we don't load huge files that won't be used
-    if 'xml' in mime_type:
+    if 'xml' in ext:
         confile = open(file, 'r')
         data = confile.read()
         confile.close()
         return xmltodict(data, 'utf-8')
-    elif 'yaml' in mime_type:
+    elif 'yaml' in ext or 'yml' in ext:
         import yaml
 
         def custom_str_constructor(loader, node):
@@ -183,7 +183,7 @@ def get_conf_dict(file):
         data = confile.read()
         confile.close()
         return yaml.load(data)
-    elif 'json' in mime_type:
+    elif 'json' in ext:
         import json
 
         confile = open(file, 'r')