streamlit-octostar-utils 0.2.4__tar.gz → 0.2.5__tar.gz
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-0.2.4 → streamlit_octostar_utils-0.2.5}/PKG-INFO +1 -1
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/pyproject.toml +1 -1
- streamlit_octostar_utils-0.2.5/streamlit_octostar_utils/core/filetypes.py +31 -0
- streamlit_octostar_utils-0.2.4/streamlit_octostar_utils/core/filetypes.py +0 -25
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/LICENSE +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/README.md +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/celery.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/fastapi.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/nifi.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/core/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/core/dict.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/core/timestamp.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/nlp/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/nlp/language.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/nlp/ner.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/octostar/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/octostar/client.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/octostar/context.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/octostar/permissions.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/ontology/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/ontology/expand_entities.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/ontology/validation.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/style/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/style/common.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/threading/__init__.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
- {streamlit_octostar_utils-0.2.4 → streamlit_octostar_utils-0.2.5}/streamlit_octostar_utils/threading/session_state_hot_swapper.py +0 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
import mimetypes
|
2
|
+
import filetype
|
3
|
+
|
4
|
+
|
5
|
+
def add_filetypes():
|
6
|
+
mimetypes.add_type("text/csv", ".csv")
|
7
|
+
|
8
|
+
|
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
|
23
|
+
if not from_file_guess and not from_name_guess:
|
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
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import mimetypes
|
2
|
-
import filetype
|
3
|
-
|
4
|
-
|
5
|
-
def add_filetypes():
|
6
|
-
mimetypes.add_type("text/csv", ".csv")
|
7
|
-
|
8
|
-
|
9
|
-
def recognize_filetype(file, filename):
|
10
|
-
from_name_guess, _ = mimetypes.guess_type(filename)
|
11
|
-
from_file_guess = filetype.guess(file)
|
12
|
-
if from_file_guess:
|
13
|
-
from_file_guess = from_file_guess.mime
|
14
|
-
recognized_filetype = None
|
15
|
-
if not from_file_guess and not from_name_guess:
|
16
|
-
recognized_filetype = "unknown"
|
17
|
-
elif not (from_file_guess and from_name_guess):
|
18
|
-
recognized_filetype = from_file_guess or from_name_guess
|
19
|
-
elif from_file_guess.split("/", 1)[0] != from_name_guess.split("/", 1)[0]:
|
20
|
-
recognized_filetype = from_file_guess
|
21
|
-
elif from_file_guess.split("/", 1)[-1] != from_name_guess.split("/", 1)[-1]:
|
22
|
-
recognized_filetype = from_name_guess
|
23
|
-
else:
|
24
|
-
recognized_filetype = from_name_guess
|
25
|
-
return recognized_filetype
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|