amsdal 0.4.13__cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.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.
- amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1334 -0
- amsdal/__about__.py +4 -0
- amsdal/__about__.pyi +1 -0
- amsdal/__init__.py +23 -0
- amsdal/__init__.pyi +9 -0
- amsdal/__migrations__/0000_initial.py +217 -0
- amsdal/__migrations__/0001_datetime_type.py +18 -0
- amsdal/__migrations__/0002_fixture_order.py +44 -0
- amsdal/__migrations__/0003_schema_type_in_class_meta.py +44 -0
- amsdal/cloud/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/__init__.pyi +0 -0
- amsdal/cloud/client.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/client.pyi +57 -0
- amsdal/cloud/constants.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/constants.pyi +13 -0
- amsdal/cloud/enums.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/enums.pyi +68 -0
- amsdal/cloud/models/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/models/__init__.pyi +0 -0
- amsdal/cloud/models/base.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/models/base.pyi +247 -0
- amsdal/cloud/services/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/__init__.pyi +0 -0
- amsdal/cloud/services/actions/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/__init__.pyi +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/add_basic_auth.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
- amsdal/cloud/services/actions/add_dependency.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_dependency.pyi +19 -0
- amsdal/cloud/services/actions/add_secret.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_secret.pyi +20 -0
- amsdal/cloud/services/actions/base.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/base.pyi +122 -0
- amsdal/cloud/services/actions/create_deploy.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/create_deploy.pyi +41 -0
- amsdal/cloud/services/actions/create_env.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/create_env.pyi +19 -0
- amsdal/cloud/services/actions/create_session.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/create_session.pyi +17 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/delete_basic_auth.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
- amsdal/cloud/services/actions/delete_dependency.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
- amsdal/cloud/services/actions/delete_env.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_env.pyi +21 -0
- amsdal/cloud/services/actions/delete_secret.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_secret.pyi +21 -0
- amsdal/cloud/services/actions/destroy_deploy.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
- amsdal/cloud/services/actions/expose_db.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/expose_db.pyi +22 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
- amsdal/cloud/services/actions/get_monitoring_info.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
- amsdal/cloud/services/actions/list_dependencies.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
- amsdal/cloud/services/actions/list_deploys.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_deploys.pyi +19 -0
- amsdal/cloud/services/actions/list_envs.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_envs.pyi +20 -0
- amsdal/cloud/services/actions/list_secrets.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_secrets.pyi +22 -0
- amsdal/cloud/services/actions/manager.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/manager.pyi +278 -0
- amsdal/cloud/services/actions/signup_action.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/signup_action.pyi +20 -0
- amsdal/cloud/services/actions/update_deploy.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/update_deploy.pyi +19 -0
- amsdal/cloud/services/auth/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/__init__.pyi +0 -0
- amsdal/cloud/services/auth/base.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/base.pyi +6 -0
- amsdal/cloud/services/auth/credentials.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/credentials.pyi +30 -0
- amsdal/cloud/services/auth/manager.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/manager.pyi +26 -0
- amsdal/cloud/services/auth/signup_service.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/signup_service.pyi +32 -0
- amsdal/cloud/services/auth/token.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/token.pyi +27 -0
- amsdal/configs/__init__.py +0 -0
- amsdal/configs/__init__.pyi +0 -0
- amsdal/configs/constants.py +33 -0
- amsdal/configs/constants.pyi +22 -0
- amsdal/configs/main.py +258 -0
- amsdal/configs/main.pyi +173 -0
- amsdal/context/__init__.py +0 -0
- amsdal/context/__init__.pyi +0 -0
- amsdal/context/manager.py +69 -0
- amsdal/context/manager.pyi +50 -0
- amsdal/contrib/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/contrib/__init__.pyi +0 -0
- amsdal/contrib/app_config.py +7 -0
- amsdal/contrib/app_config.pyi +6 -0
- amsdal/contrib/auth/__init__.py +0 -0
- amsdal/contrib/auth/__init__.pyi +0 -0
- amsdal/contrib/auth/app.py +27 -0
- amsdal/contrib/auth/app.pyi +15 -0
- amsdal/contrib/auth/decorators/__init__.py +35 -0
- amsdal/contrib/auth/decorators/__init__.pyi +6 -0
- amsdal/contrib/auth/errors.py +7 -0
- amsdal/contrib/auth/errors.pyi +4 -0
- amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
- amsdal/contrib/auth/lifecycle/__init__.py +0 -0
- amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/auth/lifecycle/consumer.py +394 -0
- amsdal/contrib/auth/lifecycle/consumer.pyi +108 -0
- amsdal/contrib/auth/migrations/0000_initial.py +84 -0
- amsdal/contrib/auth/models/__init__.py +0 -0
- amsdal/contrib/auth/models/__init__.pyi +0 -0
- amsdal/contrib/auth/models/login_session.py +118 -0
- amsdal/contrib/auth/models/login_session.pyi +37 -0
- amsdal/contrib/auth/models/permission.py +23 -0
- amsdal/contrib/auth/models/permission.pyi +18 -0
- amsdal/contrib/auth/models/user.py +106 -0
- amsdal/contrib/auth/models/user.pyi +46 -0
- amsdal/contrib/auth/settings.py +36 -0
- amsdal/contrib/auth/settings.pyi +26 -0
- amsdal/contrib/frontend_configs/__init__.py +0 -0
- amsdal/contrib/frontend_configs/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/app.py +24 -0
- amsdal/contrib/frontend_configs/app.pyi +19 -0
- amsdal/contrib/frontend_configs/constants.py +1 -0
- amsdal/contrib/frontend_configs/constants.pyi +1 -0
- amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
- amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
- amsdal/contrib/frontend_configs/conversion/convert.py +286 -0
- amsdal/contrib/frontend_configs/conversion/convert.pyi +22 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +306 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +98 -0
- amsdal/contrib/frontend_configs/migrations/0000_initial.py +256 -0
- amsdal/contrib/frontend_configs/models/__init__.py +0 -0
- amsdal/contrib/frontend_configs/models/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config.pyi +12 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator.pyi +7 -0
- amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +54 -0
- amsdal/contrib/frontend_configs/models/frontend_config_control_action.pyi +32 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator.pyi +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option.pyi +8 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.pyi +8 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option.pyi +9 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask.pyi +10 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator.pyi +15 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config.py +87 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config.pyi +35 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config.pyi +9 -0
- amsdal/contrib/frontend_configs/utils.py +29 -0
- amsdal/contrib/frontend_configs/utils.pyi +17 -0
- amsdal/errors.py +31 -0
- amsdal/errors.pyi +12 -0
- amsdal/fixtures/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/fixtures/__init__.pyi +0 -0
- amsdal/fixtures/manager.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/fixtures/manager.pyi +170 -0
- amsdal/fixtures/utils.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/fixtures/utils.pyi +9 -0
- amsdal/manager.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/manager.pyi +265 -0
- amsdal/mixins/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/mixins/__init__.pyi +0 -0
- amsdal/mixins/class_versions_mixin.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/mixins/class_versions_mixin.pyi +12 -0
- amsdal/models/__init__.py +19 -0
- amsdal/models/__init__.pyi +9 -0
- amsdal/models/core/__init__.py +0 -0
- amsdal/models/core/__init__.pyi +0 -0
- amsdal/models/core/class_object.py +37 -0
- amsdal/models/core/class_object.pyi +24 -0
- amsdal/models/core/class_object_meta.py +26 -0
- amsdal/models/core/class_object_meta.pyi +15 -0
- amsdal/models/core/class_property.py +20 -0
- amsdal/models/core/class_property.pyi +11 -0
- amsdal/models/core/class_property_meta.py +15 -0
- amsdal/models/core/class_property_meta.pyi +10 -0
- amsdal/models/core/file.py +156 -0
- amsdal/models/core/file.pyi +104 -0
- amsdal/models/core/fixture.py +25 -0
- amsdal/models/core/fixture.pyi +14 -0
- amsdal/models/core/option.py +11 -0
- amsdal/models/core/option.pyi +8 -0
- amsdal/models/core/validator.py +12 -0
- amsdal/models/core/validator.pyi +8 -0
- amsdal/models/types/__init__.py +0 -0
- amsdal/models/types/__init__.pyi +0 -0
- amsdal/models/types/object.py +26 -0
- amsdal/models/types/object.pyi +16 -0
- amsdal/py.typed +0 -0
- amsdal/queryset/__init__.py +21 -0
- amsdal/queryset/__init__.pyi +6 -0
- amsdal/schemas/__init__.py +0 -0
- amsdal/schemas/__init__.pyi +0 -0
- amsdal/schemas/core/class_object/model.json +31 -0
- amsdal/schemas/core/class_object/properties/display_name.py +9 -0
- amsdal/schemas/core/class_object_meta/model.json +59 -0
- amsdal/schemas/core/class_property/model.json +22 -0
- amsdal/schemas/core/class_property_meta/model.json +23 -0
- amsdal/schemas/core/file/hooks/pre_create.py +24 -0
- amsdal/schemas/core/file/hooks/pre_update.py +24 -0
- amsdal/schemas/core/file/model.json +23 -0
- amsdal/schemas/core/file/properties/from_file.py +34 -0
- amsdal/schemas/core/file/properties/mimetype.py +13 -0
- amsdal/schemas/core/file/properties/str.py +6 -0
- amsdal/schemas/core/file/properties/to_file.py +24 -0
- amsdal/schemas/core/file/properties/validate_data.py +32 -0
- amsdal/schemas/core/fixture/model.json +35 -0
- amsdal/schemas/core/option/model.json +19 -0
- amsdal/schemas/core/validator/model.json +19 -0
- amsdal/schemas/interfaces.py +25 -0
- amsdal/schemas/interfaces.pyi +20 -0
- amsdal/schemas/manager.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/schemas/manager.py +0 -0
- amsdal/schemas/manager.pyi +0 -0
- amsdal/schemas/mixins/__init__.py +0 -0
- amsdal/schemas/mixins/__init__.pyi +0 -0
- amsdal/schemas/mixins/check_dependencies_mixin.py +125 -0
- amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
- amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
- amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
- amsdal/schemas/repository.py +84 -0
- amsdal/schemas/repository.pyi +22 -0
- amsdal/schemas/types/anything/model.json +7 -0
- amsdal/schemas/types/array/model.json +7 -0
- amsdal/schemas/types/binary/model.json +7 -0
- amsdal/schemas/types/boolean/model.json +17 -0
- amsdal/schemas/types/date/model.json +7 -0
- amsdal/schemas/types/datetime/model.json +7 -0
- amsdal/schemas/types/dictionary/model.json +8 -0
- amsdal/schemas/types/number/model.json +8 -0
- amsdal/schemas/types/object/model.json +53 -0
- amsdal/schemas/types/string/model.json +8 -0
- amsdal/schemas/utils.py +16 -0
- amsdal/schemas/utils.pyi +10 -0
- amsdal/services/__init__.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/services/__init__.pyi +0 -0
- amsdal/services/transaction_execution.cpython-311-x86_64-linux-gnu.so +0 -0
- amsdal/services/transaction_execution.pyi +93 -0
- amsdal/transactions/__init__.py +13 -0
- amsdal/transactions/__init__.pyi +4 -0
- amsdal/utils/__init__.py +0 -0
- amsdal/utils/__init__.pyi +0 -0
- amsdal/utils/contrib_paths.py +23 -0
- amsdal/utils/contrib_paths.pyi +14 -0
- amsdal/utils/rollback/__init__.py +440 -0
- amsdal/utils/rollback/__init__.pyi +38 -0
- amsdal/utils/tests/__init__.py +0 -0
- amsdal/utils/tests/enums.py +18 -0
- amsdal/utils/tests/factories.py +49 -0
- amsdal/utils/tests/helpers.py +499 -0
- amsdal-0.4.13.dist-info/METADATA +369 -0
- amsdal-0.4.13.dist-info/RECORD +269 -0
- amsdal-0.4.13.dist-info/WHEEL +6 -0
- amsdal-0.4.13.dist-info/licenses/LICENSE.txt +107 -0
- amsdal-0.4.13.dist-info/top_level.txt +1 -0
amsdal/manager.pyi
ADDED
@@ -0,0 +1,265 @@
|
|
1
|
+
from _typeshed import Incomplete
|
2
|
+
from amsdal.cloud.services.actions.manager import CloudActionsManager as CloudActionsManager
|
3
|
+
from amsdal.cloud.services.auth.signup_service import SignupService as SignupService
|
4
|
+
from amsdal.configs.main import settings as settings
|
5
|
+
from amsdal.errors import AmsdalAuthenticationError as AmsdalAuthenticationError, AmsdalMissingCredentialsError as AmsdalMissingCredentialsError, AmsdalRuntimeError as AmsdalRuntimeError, AmsdalSignupError as AmsdalSignupError
|
6
|
+
from amsdal.fixtures.manager import AsyncFixturesManager as AsyncFixturesManager, FixturesManager as FixturesManager
|
7
|
+
from amsdal.mixins.class_versions_mixin import ClassVersionsMixin as ClassVersionsMixin
|
8
|
+
from amsdal_data.transactions.decorators import async_transaction, transaction
|
9
|
+
from amsdal_models.classes.class_manager import ClassManager
|
10
|
+
from amsdal_utils.config.data_models.amsdal_config import AmsdalConfig as AmsdalConfig
|
11
|
+
from amsdal_utils.utils.singleton import Singleton
|
12
|
+
|
13
|
+
class AmsdalManager(ClassVersionsMixin, metaclass=Singleton):
|
14
|
+
"""
|
15
|
+
Manages the AMSDAL framework components and operations.
|
16
|
+
|
17
|
+
This class is responsible for initializing, setting up, and managing various components
|
18
|
+
of the AMSDAL framework, including connections, data management, schema management,
|
19
|
+
and authentication. It also provides methods for building and tearing down the framework.
|
20
|
+
"""
|
21
|
+
_class_manager: ClassManager
|
22
|
+
_config_manager: Incomplete
|
23
|
+
_config: Incomplete
|
24
|
+
_data_application: Incomplete
|
25
|
+
_is_setup: bool
|
26
|
+
__is_authenticated: bool
|
27
|
+
_metadata_manager: Incomplete
|
28
|
+
_auth_manager: Incomplete
|
29
|
+
def __init__(self, *, raise_on_new_signup: bool = False) -> None:
|
30
|
+
"""
|
31
|
+
Initializes all sub managers. Reads the configuration.
|
32
|
+
|
33
|
+
Returns:
|
34
|
+
None
|
35
|
+
"""
|
36
|
+
@property
|
37
|
+
def is_setup(self) -> bool: ...
|
38
|
+
@property
|
39
|
+
def is_authenticated(self) -> bool:
|
40
|
+
"""
|
41
|
+
Indicates if the AMSDAL license authentication process has been passed.
|
42
|
+
|
43
|
+
This property returns a boolean value indicating whether the AMSDAL license
|
44
|
+
authentication process has been successfully completed.
|
45
|
+
|
46
|
+
Returns:
|
47
|
+
bool: True if authenticated, False otherwise.
|
48
|
+
"""
|
49
|
+
def pre_setup(self) -> None:
|
50
|
+
"""
|
51
|
+
Initiates models root path and adds it into sys.path.
|
52
|
+
|
53
|
+
This method initializes the class manager models modules and sets up the models root path
|
54
|
+
as specified in the settings. It ensures that the models root path is added
|
55
|
+
to the system path for proper module resolution.
|
56
|
+
|
57
|
+
Returns:
|
58
|
+
None
|
59
|
+
"""
|
60
|
+
def setup(self) -> None:
|
61
|
+
"""
|
62
|
+
Initiates models root path and the connections.
|
63
|
+
|
64
|
+
This method sets up the AMSDAL framework by initializing the models root path and
|
65
|
+
establishing connections. It ensures that the setup process is only performed once.
|
66
|
+
|
67
|
+
Raises:
|
68
|
+
AmsdalRuntimeError: If the AMSDAL manager is already set up.
|
69
|
+
|
70
|
+
Returns:
|
71
|
+
None
|
72
|
+
"""
|
73
|
+
@transaction
|
74
|
+
def post_setup(self) -> None:
|
75
|
+
"""
|
76
|
+
Registers internal classes and prepares connections (creates internal tables).
|
77
|
+
"""
|
78
|
+
def _check_auth(self) -> None: ...
|
79
|
+
@property
|
80
|
+
def cloud_actions_manager(self) -> CloudActionsManager:
|
81
|
+
"""
|
82
|
+
Provides access to the CloudActionsManager.
|
83
|
+
|
84
|
+
This property checks if the AMSDAL manager is authenticated and then returns
|
85
|
+
an instance of the CloudActionsManager.
|
86
|
+
|
87
|
+
Returns:
|
88
|
+
CloudActionsManager: An instance of the CloudActionsManager.
|
89
|
+
|
90
|
+
Raises:
|
91
|
+
AmsdalAuthenticationError: If the AMSDAL manager is not authenticated.
|
92
|
+
"""
|
93
|
+
def authenticate(self) -> None:
|
94
|
+
"""
|
95
|
+
Run AMSDAL license authentication process.
|
96
|
+
|
97
|
+
This method runs the AMSDAL license authentication process and sets the
|
98
|
+
authentication status accordingly.
|
99
|
+
|
100
|
+
Returns:
|
101
|
+
None
|
102
|
+
"""
|
103
|
+
@transaction
|
104
|
+
def apply_fixtures(self) -> None:
|
105
|
+
"""
|
106
|
+
Loads and applies fixtures defined in your application.
|
107
|
+
|
108
|
+
This method loads the fixtures from the specified path and applies them to the
|
109
|
+
AMSDAL framework. It uses the `FixturesManager` to manage the loading and application
|
110
|
+
of the fixtures.
|
111
|
+
|
112
|
+
Returns:
|
113
|
+
None
|
114
|
+
"""
|
115
|
+
def init_classes(self) -> None:
|
116
|
+
"""
|
117
|
+
Initializes and imports classes based on the schema manager's class schemas.
|
118
|
+
|
119
|
+
This method iterates over the class schemas provided by the schema manager and imports
|
120
|
+
the classes into the class manager, excluding those of type `SchemaTypes.TYPE`.
|
121
|
+
|
122
|
+
Returns:
|
123
|
+
None
|
124
|
+
"""
|
125
|
+
def teardown(self) -> None:
|
126
|
+
"""
|
127
|
+
Clean up everything on the application exit.
|
128
|
+
|
129
|
+
This method performs a cleanup of all components managed by the AMSDAL framework
|
130
|
+
when the application exits. It disconnects and invalidates connections, clears caches,
|
131
|
+
and resets the setup status.
|
132
|
+
|
133
|
+
Raises:
|
134
|
+
AmsdalRuntimeError: If the AMSDAL manager is not set up.
|
135
|
+
|
136
|
+
Returns:
|
137
|
+
None
|
138
|
+
"""
|
139
|
+
|
140
|
+
class AsyncAmsdalManager(ClassVersionsMixin, metaclass=Singleton):
|
141
|
+
"""
|
142
|
+
Manages the AMSDAL framework components and operations.
|
143
|
+
|
144
|
+
This class is responsible for initializing, setting up, and managing various components
|
145
|
+
of the AMSDAL framework, including connections, data management, schema management,
|
146
|
+
and authentication. It also provides methods for building and tearing down the framework.
|
147
|
+
"""
|
148
|
+
_class_manager: ClassManager
|
149
|
+
_config_manager: Incomplete
|
150
|
+
_config: Incomplete
|
151
|
+
_data_application: Incomplete
|
152
|
+
_is_setup: bool
|
153
|
+
__is_authenticated: bool
|
154
|
+
_metadata_manager: Incomplete
|
155
|
+
_auth_manager: Incomplete
|
156
|
+
def __init__(self, *, raise_on_new_signup: bool = False) -> None:
|
157
|
+
"""
|
158
|
+
Initializes all sub managers. Reads the configuration.
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
None
|
162
|
+
"""
|
163
|
+
@property
|
164
|
+
def is_setup(self) -> bool: ...
|
165
|
+
@property
|
166
|
+
def is_authenticated(self) -> bool:
|
167
|
+
"""
|
168
|
+
Indicates if the AMSDAL license authentication process has been passed.
|
169
|
+
|
170
|
+
This property returns a boolean value indicating whether the AMSDAL license
|
171
|
+
authentication process has been successfully completed.
|
172
|
+
|
173
|
+
Returns:
|
174
|
+
bool: True if authenticated, False otherwise.
|
175
|
+
"""
|
176
|
+
def pre_setup(self) -> None:
|
177
|
+
"""
|
178
|
+
Initiates models root path and adds it into sys.path.
|
179
|
+
|
180
|
+
This method initializes the class manager and sets up the models root path
|
181
|
+
as specified in the settings. It ensures that the models root path is added
|
182
|
+
to the system path for proper module resolution.
|
183
|
+
|
184
|
+
Returns:
|
185
|
+
None
|
186
|
+
"""
|
187
|
+
async def setup(self) -> None:
|
188
|
+
"""
|
189
|
+
Initiates models root path and the connections.
|
190
|
+
|
191
|
+
This method sets up the AMSDAL framework by initializing the models root path and
|
192
|
+
establishing connections. It ensures that the setup process is only performed once.
|
193
|
+
|
194
|
+
Raises:
|
195
|
+
AmsdalRuntimeError: If the AMSDAL manager is already set up.
|
196
|
+
|
197
|
+
Returns:
|
198
|
+
None
|
199
|
+
"""
|
200
|
+
@async_transaction
|
201
|
+
async def post_setup(self) -> None:
|
202
|
+
"""
|
203
|
+
Registers internal classes and prepares connections (creates internal tables).
|
204
|
+
"""
|
205
|
+
def _check_auth(self) -> None: ...
|
206
|
+
@property
|
207
|
+
def cloud_actions_manager(self) -> CloudActionsManager:
|
208
|
+
"""
|
209
|
+
Provides access to the CloudActionsManager.
|
210
|
+
|
211
|
+
This property checks if the AMSDAL manager is authenticated and then returns
|
212
|
+
an instance of the CloudActionsManager.
|
213
|
+
|
214
|
+
Returns:
|
215
|
+
CloudActionsManager: An instance of the CloudActionsManager.
|
216
|
+
|
217
|
+
Raises:
|
218
|
+
AmsdalAuthenticationError: If the AMSDAL manager is not authenticated.
|
219
|
+
"""
|
220
|
+
def authenticate(self) -> None:
|
221
|
+
"""
|
222
|
+
Run AMSDAL license authentication process.
|
223
|
+
|
224
|
+
This method runs the AMSDAL license authentication process and sets the
|
225
|
+
authentication status accordingly.
|
226
|
+
|
227
|
+
Returns:
|
228
|
+
None
|
229
|
+
"""
|
230
|
+
@async_transaction
|
231
|
+
async def apply_fixtures(self) -> None:
|
232
|
+
"""
|
233
|
+
Loads and applies fixtures defined in your application.
|
234
|
+
|
235
|
+
This method loads the fixtures from the specified path and applies them to the
|
236
|
+
AMSDAL framework. It uses the `FixturesManager` to manage the loading and application
|
237
|
+
of the fixtures.
|
238
|
+
|
239
|
+
Returns:
|
240
|
+
None
|
241
|
+
"""
|
242
|
+
def init_classes(self) -> None:
|
243
|
+
"""
|
244
|
+
Initializes and imports classes based on the schema manager's class schemas.
|
245
|
+
|
246
|
+
This method iterates over the class schemas provided by the schema manager and imports
|
247
|
+
the classes into the class manager, excluding those of type `SchemaTypes.TYPE`.
|
248
|
+
|
249
|
+
Returns:
|
250
|
+
None
|
251
|
+
"""
|
252
|
+
async def teardown(self) -> None:
|
253
|
+
"""
|
254
|
+
Clean up everything on the application exit.
|
255
|
+
|
256
|
+
This method performs a cleanup of all components managed by the AMSDAL framework
|
257
|
+
when the application exits. It disconnects and invalidates connections, clears caches,
|
258
|
+
and resets the setup status.
|
259
|
+
|
260
|
+
Raises:
|
261
|
+
AmsdalRuntimeError: If the AMSDAL manager is not set up.
|
262
|
+
|
263
|
+
Returns:
|
264
|
+
None
|
265
|
+
"""
|
Binary file
|
File without changes
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from amsdal_data.connections.historical.schema_version_manager import AsyncHistoricalSchemaVersionManager, HistoricalSchemaVersionManager
|
2
|
+
|
3
|
+
class ClassVersionsMixin:
|
4
|
+
"""
|
5
|
+
Mixin class to manage class versions and related table schemas.
|
6
|
+
"""
|
7
|
+
@staticmethod
|
8
|
+
def _register_internal_classes(schema_version_manager: HistoricalSchemaVersionManager | AsyncHistoricalSchemaVersionManager) -> None: ...
|
9
|
+
@classmethod
|
10
|
+
def register_internal_classes(cls) -> None: ...
|
11
|
+
@classmethod
|
12
|
+
def aregister_internal_classes(cls) -> None: ...
|
@@ -0,0 +1,19 @@
|
|
1
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
2
|
+
from amsdal_models.builder.validators.options_validators import validate_options
|
3
|
+
from amsdal_models.classes.data_models.constraints import UniqueConstraint
|
4
|
+
from amsdal_models.classes.data_models.indexes import IndexInfo
|
5
|
+
from amsdal_models.classes.model import Model
|
6
|
+
from amsdal_models.classes.model import TypeModel
|
7
|
+
from amsdal_models.classes.relationships.many_reference_field import ManyReferenceField
|
8
|
+
from amsdal_models.classes.relationships.reference_field import ReferenceField
|
9
|
+
|
10
|
+
__all__ = [
|
11
|
+
'IndexInfo',
|
12
|
+
'ManyReferenceField',
|
13
|
+
'Model',
|
14
|
+
'ReferenceField',
|
15
|
+
'TypeModel',
|
16
|
+
'UniqueConstraint',
|
17
|
+
'validate_non_empty_keys',
|
18
|
+
'validate_options',
|
19
|
+
]
|
@@ -0,0 +1,9 @@
|
|
1
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys as validate_non_empty_keys
|
2
|
+
from amsdal_models.builder.validators.options_validators import validate_options as validate_options
|
3
|
+
from amsdal_models.classes.data_models.constraints import UniqueConstraint as UniqueConstraint
|
4
|
+
from amsdal_models.classes.data_models.indexes import IndexInfo as IndexInfo
|
5
|
+
from amsdal_models.classes.model import Model as Model, TypeModel as TypeModel
|
6
|
+
from amsdal_models.classes.relationships.many_reference_field import ManyReferenceField as ManyReferenceField
|
7
|
+
from amsdal_models.classes.relationships.reference_field import ReferenceField as ReferenceField
|
8
|
+
|
9
|
+
__all__ = ['IndexInfo', 'ManyReferenceField', 'Model', 'ReferenceField', 'TypeModel', 'UniqueConstraint', 'validate_non_empty_keys', 'validate_options']
|
File without changes
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from typing import ClassVar
|
3
|
+
from typing import Optional
|
4
|
+
|
5
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
6
|
+
from amsdal_models.classes.model import Model
|
7
|
+
from amsdal_utils.models.enums import ModuleType
|
8
|
+
from pydantic.fields import Field
|
9
|
+
from pydantic.functional_validators import field_validator
|
10
|
+
|
11
|
+
from amsdal.models.core.class_property import * # noqa: F403
|
12
|
+
|
13
|
+
|
14
|
+
class ClassObject(Model):
|
15
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
16
|
+
properties: Optional[dict[str, Optional['ClassProperty']]] = Field(None, title='Properties') # noqa: F405, UP007
|
17
|
+
table_name: Optional[str] = Field(None, title='Table name') # noqa: UP007
|
18
|
+
primary_key: Optional[list[str]] = Field(None, title='Primary key fields') # noqa: UP007
|
19
|
+
indexed: Optional[list[str]] = Field(None, title='Indexed') # noqa: UP007
|
20
|
+
unique: Optional[list[list[str]]] = Field(None, title='Unique Fields') # noqa: UP007
|
21
|
+
required: Optional[list[str]] = Field(None, title='Required') # noqa: UP007
|
22
|
+
meta_class: Optional[str] = Field('ClassObject', title='Meta Class') # noqa: UP007
|
23
|
+
|
24
|
+
@field_validator('properties')
|
25
|
+
@classmethod
|
26
|
+
def _non_empty_keys_properties(cls: type, value: Any) -> Any:
|
27
|
+
return validate_non_empty_keys(value)
|
28
|
+
|
29
|
+
@property
|
30
|
+
def display_name(self) -> str:
|
31
|
+
"""
|
32
|
+
Returns the display name of the object.
|
33
|
+
|
34
|
+
Returns:
|
35
|
+
str: The display name, which is the title of the object.
|
36
|
+
"""
|
37
|
+
return self.title
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from amsdal.models.core.class_property import *
|
2
|
+
from amsdal_models.classes.model import Model
|
3
|
+
from amsdal_utils.models.enums import ModuleType
|
4
|
+
from typing import Any, ClassVar
|
5
|
+
|
6
|
+
class ClassObject(Model):
|
7
|
+
__module_type__: ClassVar[ModuleType] = ...
|
8
|
+
properties: dict[str, ClassProperty | None] | None = ...
|
9
|
+
table_name: str | None = ...
|
10
|
+
primary_key: list[str] | None = ...
|
11
|
+
indexed: list[str] | None = ...
|
12
|
+
unique: list[list[str]] | None = ...
|
13
|
+
required: list[str] | None = ...
|
14
|
+
meta_class: str | None = ...
|
15
|
+
@classmethod
|
16
|
+
def _non_empty_keys_properties(cls, value: Any) -> Any: ...
|
17
|
+
@property
|
18
|
+
def display_name(self) -> str:
|
19
|
+
"""
|
20
|
+
Returns the display name of the object.
|
21
|
+
|
22
|
+
Returns:
|
23
|
+
str: The display name, which is the title of the object.
|
24
|
+
"""
|
@@ -0,0 +1,26 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from typing import ClassVar
|
3
|
+
from typing import Optional
|
4
|
+
|
5
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
6
|
+
from amsdal_models.classes.model import Model
|
7
|
+
from amsdal_utils.models.enums import ModuleType
|
8
|
+
from pydantic.fields import Field
|
9
|
+
from pydantic.functional_validators import field_validator
|
10
|
+
|
11
|
+
from amsdal.models.core.class_property_meta import * # noqa: F403
|
12
|
+
|
13
|
+
|
14
|
+
class ClassObjectMeta(Model):
|
15
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
16
|
+
title: str = Field(title='Title')
|
17
|
+
type: str = Field(title='Type')
|
18
|
+
default: Any | None = Field(None, title='Default')
|
19
|
+
class_schema_type: str | None = Field(None, title='Schema Type')
|
20
|
+
properties: dict[str, Optional['ClassPropertyMeta']] | None = Field(None, title='Properties') # noqa: F405
|
21
|
+
custom_code: str | None = Field(None, title='Custom Code')
|
22
|
+
|
23
|
+
@field_validator('properties')
|
24
|
+
@classmethod
|
25
|
+
def _non_empty_keys_properties(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
|
26
|
+
return validate_non_empty_keys(value)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from amsdal.models.core.class_property_meta import *
|
2
|
+
from amsdal_models.classes.model import Model
|
3
|
+
from amsdal_utils.models.enums import ModuleType
|
4
|
+
from typing import Any, ClassVar
|
5
|
+
|
6
|
+
class ClassObjectMeta(Model):
|
7
|
+
__module_type__: ClassVar[ModuleType] = ...
|
8
|
+
title: str = ...
|
9
|
+
type: str = ...
|
10
|
+
default: Any | None = ...
|
11
|
+
class_schema_type: str | None = ...
|
12
|
+
properties: dict[str, ClassPropertyMeta | None] | None = ...
|
13
|
+
custom_code: str | None = ...
|
14
|
+
@classmethod
|
15
|
+
def _non_empty_keys_properties(cls, value: Any) -> Any: ...
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from typing import ClassVar
|
3
|
+
|
4
|
+
from amsdal_models.builder.validators.dict_validators import validate_non_empty_keys
|
5
|
+
from amsdal_models.classes.model import TypeModel
|
6
|
+
from amsdal_utils.models.enums import ModuleType
|
7
|
+
from pydantic.fields import Field
|
8
|
+
from pydantic.functional_validators import field_validator
|
9
|
+
|
10
|
+
|
11
|
+
class ClassProperty(TypeModel):
|
12
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
13
|
+
type: str = Field(title='Type')
|
14
|
+
items: dict[str, Any | None] | None = Field(None, title='Items')
|
15
|
+
db_field: list[str] | None = Field(None, title='DB Fields')
|
16
|
+
|
17
|
+
@field_validator('items')
|
18
|
+
@classmethod
|
19
|
+
def _non_empty_keys_items(cls: type, value: Any) -> Any: # type: ignore # noqa: A003
|
20
|
+
return validate_non_empty_keys(value)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from amsdal_models.classes.model import TypeModel
|
2
|
+
from amsdal_utils.models.enums import ModuleType
|
3
|
+
from typing import Any, ClassVar
|
4
|
+
|
5
|
+
class ClassProperty(TypeModel):
|
6
|
+
__module_type__: ClassVar[ModuleType]
|
7
|
+
type: str
|
8
|
+
items: dict[str, Any | None] | None
|
9
|
+
db_field: list[str] | None
|
10
|
+
@classmethod
|
11
|
+
def _non_empty_keys_items(cls, value: Any) -> Any: ...
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from typing import ClassVar
|
3
|
+
|
4
|
+
from amsdal_models.classes.model import TypeModel
|
5
|
+
from amsdal_utils.models.enums import ModuleType
|
6
|
+
from pydantic.fields import Field
|
7
|
+
|
8
|
+
from amsdal.models.core.option import * # noqa: F403
|
9
|
+
|
10
|
+
|
11
|
+
class ClassPropertyMeta(TypeModel):
|
12
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
13
|
+
title: str | None = Field(None, title='Title')
|
14
|
+
default: Any | None = Field(None, title='Default')
|
15
|
+
options: list['Option'] | None = Field(None, title='Options') # noqa: F405
|
@@ -0,0 +1,10 @@
|
|
1
|
+
from amsdal.models.core.option import *
|
2
|
+
from amsdal_models.classes.model import TypeModel
|
3
|
+
from amsdal_utils.models.enums import ModuleType
|
4
|
+
from typing import Any, ClassVar
|
5
|
+
|
6
|
+
class ClassPropertyMeta(TypeModel):
|
7
|
+
__module_type__: ClassVar[ModuleType]
|
8
|
+
title: str | None
|
9
|
+
default: Any | None
|
10
|
+
options: list['Option'] | None
|
@@ -0,0 +1,156 @@
|
|
1
|
+
import base64
|
2
|
+
from pathlib import Path
|
3
|
+
from typing import BinaryIO
|
4
|
+
from typing import ClassVar
|
5
|
+
|
6
|
+
from amsdal_models.classes.model import Model
|
7
|
+
from amsdal_utils.models.enums import ModuleType
|
8
|
+
from pydantic import field_validator
|
9
|
+
from pydantic.fields import Field
|
10
|
+
|
11
|
+
|
12
|
+
class File(Model):
|
13
|
+
__module_type__: ClassVar[ModuleType] = ModuleType.CORE
|
14
|
+
filename: str = Field(title='Filename')
|
15
|
+
data: bytes = Field(title='Data')
|
16
|
+
size: float | None = Field(None, title='Size')
|
17
|
+
|
18
|
+
def __repr__(self) -> str:
|
19
|
+
return f'File<{self.filename}>({self.size or len(self.data) or 0} bytes)'
|
20
|
+
|
21
|
+
def __str__(self) -> str:
|
22
|
+
return repr(self)
|
23
|
+
|
24
|
+
async def apre_create(self) -> None:
|
25
|
+
"""
|
26
|
+
Prepares the object for creation by setting its size attribute.
|
27
|
+
|
28
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
29
|
+
If the data is None, it defaults to an empty byte string.
|
30
|
+
|
31
|
+
Args:
|
32
|
+
None
|
33
|
+
"""
|
34
|
+
self.size = len(self.data or b'')
|
35
|
+
|
36
|
+
async def apre_update(self) -> None:
|
37
|
+
"""
|
38
|
+
Prepares the object for update by setting its size attribute.
|
39
|
+
|
40
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
41
|
+
If the data is None, it defaults to an empty byte string.
|
42
|
+
|
43
|
+
Args:
|
44
|
+
None
|
45
|
+
"""
|
46
|
+
self.size = len(self.data or b'')
|
47
|
+
|
48
|
+
@field_validator('data')
|
49
|
+
@classmethod
|
50
|
+
def data_base64_decode(cls, v: bytes) -> bytes:
|
51
|
+
"""
|
52
|
+
Decodes a base64-encoded byte string if it is base64-encoded.
|
53
|
+
|
54
|
+
This method checks if the provided byte string is base64-encoded and decodes it if true.
|
55
|
+
If the byte string is not base64-encoded, it returns the original byte string.
|
56
|
+
|
57
|
+
Args:
|
58
|
+
cls: The class this method belongs to.
|
59
|
+
v (bytes): The byte string to be checked and potentially decoded.
|
60
|
+
|
61
|
+
Returns:
|
62
|
+
bytes: The decoded byte string if it was base64-encoded, otherwise the original byte string.
|
63
|
+
"""
|
64
|
+
is_base64: bool = False
|
65
|
+
try:
|
66
|
+
is_base64 = base64.b64encode(base64.b64decode(v)) == v
|
67
|
+
except Exception:
|
68
|
+
...
|
69
|
+
if is_base64:
|
70
|
+
return base64.b64decode(v)
|
71
|
+
return v
|
72
|
+
|
73
|
+
@classmethod
|
74
|
+
def from_file(cls, file_or_path: Path | BinaryIO) -> 'File':
|
75
|
+
"""
|
76
|
+
Creates a `File` object from a file path or a binary file object.
|
77
|
+
|
78
|
+
Args:
|
79
|
+
file_or_path (Path | BinaryIO): The file path or binary file object.
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
File: The created `File` object.
|
83
|
+
|
84
|
+
Raises:
|
85
|
+
ValueError: If the provided path is a directory.
|
86
|
+
"""
|
87
|
+
if isinstance(file_or_path, Path):
|
88
|
+
if file_or_path.is_dir():
|
89
|
+
msg = f'{file_or_path} is a directory'
|
90
|
+
raise ValueError(msg)
|
91
|
+
data = file_or_path.read_bytes()
|
92
|
+
filename = file_or_path.name
|
93
|
+
else:
|
94
|
+
file_or_path.seek(0)
|
95
|
+
data = file_or_path.read()
|
96
|
+
filename = Path(file_or_path.name).name
|
97
|
+
return cls(data=data, filename=filename) # type: ignore[call-arg]
|
98
|
+
|
99
|
+
@property
|
100
|
+
def mimetype(self) -> str | None:
|
101
|
+
"""
|
102
|
+
Returns the MIME type of the file based on its filename.
|
103
|
+
|
104
|
+
This method uses the `mimetypes` module to guess the MIME type of the file.
|
105
|
+
|
106
|
+
Returns:
|
107
|
+
str | None: The guessed MIME type of the file, or None if it cannot be determined.
|
108
|
+
"""
|
109
|
+
import mimetypes
|
110
|
+
|
111
|
+
return mimetypes.guess_type(self.filename)[0]
|
112
|
+
|
113
|
+
def pre_create(self) -> None:
|
114
|
+
"""
|
115
|
+
Prepares the object for creation by setting its size attribute.
|
116
|
+
|
117
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
118
|
+
If the data is None, it defaults to an empty byte string.
|
119
|
+
|
120
|
+
Args:
|
121
|
+
None
|
122
|
+
"""
|
123
|
+
self.size = len(self.data or b'')
|
124
|
+
|
125
|
+
def pre_update(self) -> None:
|
126
|
+
"""
|
127
|
+
Prepares the object for update by setting its size attribute.
|
128
|
+
|
129
|
+
This method calculates the size of the object's data and assigns it to the size attribute.
|
130
|
+
If the data is None, it defaults to an empty byte string.
|
131
|
+
|
132
|
+
Args:
|
133
|
+
None
|
134
|
+
"""
|
135
|
+
self.size = len(self.data or b'')
|
136
|
+
|
137
|
+
def to_file(self, file_or_path: Path | BinaryIO) -> None:
|
138
|
+
"""
|
139
|
+
Writes the object's data to a file path or a binary file object.
|
140
|
+
|
141
|
+
Args:
|
142
|
+
file_or_path (Path | BinaryIO): The file path or binary file object where the data will be written.
|
143
|
+
|
144
|
+
Returns:
|
145
|
+
None
|
146
|
+
|
147
|
+
Raises:
|
148
|
+
ValueError: If the provided path is a directory.
|
149
|
+
"""
|
150
|
+
if isinstance(file_or_path, Path):
|
151
|
+
if file_or_path.is_dir():
|
152
|
+
file_or_path = file_or_path / self.name
|
153
|
+
file_or_path.write_bytes(self.data) # type: ignore[union-attr]
|
154
|
+
else:
|
155
|
+
file_or_path.write(self.data)
|
156
|
+
file_or_path.seek(0)
|