agi-med-common 3.5.3__tar.gz → 3.5.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.
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/PKG-INFO +2 -2
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/__init__.py +1 -1
- agi_med_common-3.5.5/src/agi_med_common/file_storage.py +39 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/action_enum.py +1 -1
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/track_id_enum.py +2 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common.egg-info/PKG-INFO +2 -2
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common.egg-info/SOURCES.txt +1 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/README.md +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/pyproject.toml +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/requirements.txt +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/setup.cfg +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/logger/__init__.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/logger/log_level_enum.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/logger/logger.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/__init__.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/_base.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/base_config_models/__init__.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/base_config_models/gigachat_config.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/__init__.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/chat_item.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/inner_context_item.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/outer_context_item.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/replica_item.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/__init__.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/diagnostics_xml_tag_enum.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/doctor_choice_xml_tag_enum.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/moderation_label_enum.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/mtrs_label_enum.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/mtrs_xml_tag_enum.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/state_enum.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/utils.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/validators.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/xml_parser.py +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common.egg-info/dependency_links.txt +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common.egg-info/requires.txt +0 -0
- {agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common.egg-info/top_level.txt +0 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
import string
|
2
|
+
from hashlib import md5
|
3
|
+
from pathlib import Path
|
4
|
+
|
5
|
+
ResourceId = str
|
6
|
+
ASCII_DIGITS = set(string.ascii_lowercase + string.digits)
|
7
|
+
|
8
|
+
|
9
|
+
def _validate_exist(files_dir):
|
10
|
+
if not files_dir.exists():
|
11
|
+
err = f"Failed to access file-storage directory: {files_dir}"
|
12
|
+
raise OSError(err)
|
13
|
+
|
14
|
+
|
15
|
+
def _validate_dtype(dtype: str):
|
16
|
+
if all(map(ASCII_DIGITS.__contains__, dtype)):
|
17
|
+
return
|
18
|
+
raise ValueError(f'Bad dtype: {dtype}')
|
19
|
+
|
20
|
+
|
21
|
+
class FileStorage:
|
22
|
+
def __init__(self, files_dir):
|
23
|
+
self.files_dir = Path(files_dir)
|
24
|
+
self.files_dir.mkdir(exist_ok=True)
|
25
|
+
_validate_exist(self.files_dir)
|
26
|
+
|
27
|
+
def upload(self, content: bytes, dtype: str) -> ResourceId | None:
|
28
|
+
_validate_dtype(dtype)
|
29
|
+
fname_hash = md5(content).hexdigest()
|
30
|
+
fname = f'{fname_hash}.{dtype}'
|
31
|
+
fpath = self.files_dir / fname
|
32
|
+
fpath.write_bytes(content)
|
33
|
+
return str(fpath)
|
34
|
+
|
35
|
+
def download(self, rid: ResourceId) -> bytes:
|
36
|
+
return Path(rid).read_bytes()
|
37
|
+
|
38
|
+
def is_valid(self, rid: ResourceId) -> bytes:
|
39
|
+
return Path(rid).exists() and Path(rid).is_file()
|
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
|
{agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/__init__.py
RENAMED
File without changes
|
{agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/chat_item.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/chat_item/replica_item.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/mtrs_label_enum.py
RENAMED
File without changes
|
{agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common/models/enums/mtrs_xml_tag_enum.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{agi_med_common-3.5.3 → agi_med_common-3.5.5}/src/agi_med_common.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|