streamlit-octostar-utils 0.2.4__py3-none-any.whl → 0.2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit_octostar_utils/core/filetypes.py +22 -16
- {streamlit_octostar_utils-0.2.4.dist-info → streamlit_octostar_utils-0.2.5.dist-info}/METADATA +1 -1
- {streamlit_octostar_utils-0.2.4.dist-info → streamlit_octostar_utils-0.2.5.dist-info}/RECORD +5 -5
- {streamlit_octostar_utils-0.2.4.dist-info → streamlit_octostar_utils-0.2.5.dist-info}/LICENSE +0 -0
- {streamlit_octostar_utils-0.2.4.dist-info → streamlit_octostar_utils-0.2.5.dist-info}/WHEEL +0 -0
@@ -6,20 +6,26 @@ def add_filetypes():
|
|
6
6
|
mimetypes.add_type("text/csv", ".csv")
|
7
7
|
|
8
8
|
|
9
|
-
def recognize_filetype(file, filename):
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
def recognize_filetype(file=None, filename=None):
|
10
|
+
if not (file or filename):
|
11
|
+
raise ValueError("Must provide either file content or filename")
|
12
|
+
from_name_guess = None
|
13
|
+
from_file_guess = None
|
14
|
+
if filename:
|
15
|
+
from_name_guess, _ = mimetypes.guess_type(filename)
|
16
|
+
if file:
|
17
|
+
ft = filetype.guess(file)
|
18
|
+
from_file_guess = ft.mime if ft else None
|
19
|
+
def _family(m):
|
20
|
+
return m.split("/", 1)[0] if isinstance(m, str) and "/" in m else None
|
21
|
+
def _subtype(m):
|
22
|
+
return m.split("/", 1)[-1] if isinstance(m, str) and "/" in m else None
|
15
23
|
if not from_file_guess and not from_name_guess:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
recognized_filetype = from_name_guess
|
25
|
-
return recognized_filetype
|
24
|
+
return "unknown"
|
25
|
+
if not (from_file_guess and from_name_guess):
|
26
|
+
return from_file_guess or from_name_guess
|
27
|
+
if _family(from_file_guess) != _family(from_name_guess):
|
28
|
+
return from_file_guess
|
29
|
+
if _subtype(from_file_guess) != _subtype(from_name_guess):
|
30
|
+
return from_name_guess
|
31
|
+
return from_name_guess
|
{streamlit_octostar_utils-0.2.4.dist-info → streamlit_octostar_utils-0.2.5.dist-info}/RECORD
RENAMED
@@ -15,7 +15,7 @@ streamlit_octostar_utils/api_crafter/parser/rules.py,sha256=hY2saX-CYpDBoxfK7BqZ
|
|
15
15
|
streamlit_octostar_utils/api_crafter/parser/signals.py,sha256=cX1mHHGoolls7DBUwBZNHItlkKNYImEIUrr4M3btQko,4408
|
16
16
|
streamlit_octostar_utils/core/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
17
17
|
streamlit_octostar_utils/core/dict.py,sha256=b-gOCXLNuTY6WePCOeq20QLYHAPHpfivG6sxZZMw-b8,2802
|
18
|
-
streamlit_octostar_utils/core/filetypes.py,sha256=
|
18
|
+
streamlit_octostar_utils/core/filetypes.py,sha256=kOcEnQUj4RKkyIekhrBzDBQsgWHDNe12JiQjt3mlUNc,1104
|
19
19
|
streamlit_octostar_utils/core/threading/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
20
20
|
streamlit_octostar_utils/core/threading/key_queue.py,sha256=7CJpj0gvZMQd8eC5wKQi3Ak5SQQ4zQ1OPTs_OP_kD20,2255
|
21
21
|
streamlit_octostar_utils/core/timestamp.py,sha256=a3s4xfm1nctLzYsHOJxqoWIDTdbNY_yN1OByl8ahLc8,383
|
@@ -36,7 +36,7 @@ streamlit_octostar_utils/threading/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzp
|
|
36
36
|
streamlit_octostar_utils/threading/async_task_manager.py,sha256=q7N6YZwUvIYMzkSHmsJNheNVCv93c03H6Hyg9uH8pvk,4747
|
37
37
|
streamlit_octostar_utils/threading/session_callback_manager.py,sha256=LvZVP4g6tvKtYmI13f2j1sX_7hm61Groqp5xJine9_k,3973
|
38
38
|
streamlit_octostar_utils/threading/session_state_hot_swapper.py,sha256=6eeCQI6A42hp4DmW2NQw2rbeR-k9N8DhfBKQdN_fbLU,811
|
39
|
-
streamlit_octostar_utils-0.2.
|
40
|
-
streamlit_octostar_utils-0.2.
|
41
|
-
streamlit_octostar_utils-0.2.
|
42
|
-
streamlit_octostar_utils-0.2.
|
39
|
+
streamlit_octostar_utils-0.2.5.dist-info/LICENSE,sha256=dkwVPyV03fPHHtERnF6RnvRXcll__tud9gWca1RcgnQ,1073
|
40
|
+
streamlit_octostar_utils-0.2.5.dist-info/METADATA,sha256=3wOatPx3Q2H3rqp3Y9ynkoKTeNf77SlL2YK-DdhgaPE,2256
|
41
|
+
streamlit_octostar_utils-0.2.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
42
|
+
streamlit_octostar_utils-0.2.5.dist-info/RECORD,,
|
{streamlit_octostar_utils-0.2.4.dist-info → streamlit_octostar_utils-0.2.5.dist-info}/LICENSE
RENAMED
File without changes
|
File without changes
|